NAME

WWW::Live::Auth - A Microsoft Live authentication client

VERSION

1.0.0

DESCRIPTION

Provides delegated authentication functionality for Microsoft Live services.

SYNOPSIS

# Construct a client object
my $client = WWW::Live::Auth->new(
  application_id => $appid,  # string
  secret_key     => $secret, # string or WWW::Live::Auth::SecretKey object
  client_ip      => $ip      # optional
);

# Set the proxy (if necessary)
$client->proxy( 'http://proxy.mycompany.com' );

# Obtain a URL to which a user may be directed in order to grant consent
my $url = $client->consent_url(
  offers      => 'ContactsSync.FullSync',                    # required
  privacy_url => 'http://mycompany.com/privacy_policy.html', # required
  return_url  => 'http://mycompany.com/receive_consent.cgi',
  market      => 'en-gb',
  context     => '/interesting.html',
);

# Parse an incoming consent notification
my ( $token, $context ) = $client->receive_consent();

# Refresh a consent token
if ( $token->expires < time() ) {
  $token = $client->refresh_consent( consent_token => $token );
}

METHODS

new

Constructs a new authentication client for the application/client.

my $client = WWW::Live::Auth->new(
  application_id => $appid,
  secret_key     => $secret,
  client_ip      => $ip,     # optional
)

The application ID and secret key are unique to your application. See
L<http://msdn.microsoft.com/en-us/library/cc287659.aspx> for details.

proxy

Passes proxy settings through to LWP::UserAgent. Note the proxy must be
capable of proxying HTTPS connections.

$client->proxy( 'http://proxy.mycompany.com' );
Generates a URL to which a user can be directed in order to grant consent for
the application to access one or more actions.

my $url = $client->consent_url(
  offers      => 'ContactsSync.FullSync',                    # required
  privacy_url => 'http://mycompany.com/privacy_policy.html', # required
  return_url  => 'http://mycompany.com/receive_consent.cgi',
  market      => 'en-gb',
  context     => '/interesting.html',
);

"Offers" is a comma separated list of actions offered by a resource provider.
Once the user grants consent by visiting the URL, (s)he will be redirected to
the return URL, along with a parameter indicating the application context.
Extracts the consent token and application context from an incoming HTTP
request. An optional CGI object may be provided as the source of the data. If
omitted, one will be created.

my ( $token, $context ) = $client->receive_consent( $cgi );
Automatically refreshes an expired consent token.

if ( $token->expires < time() ) {
  $token = $client->refresh_consent(
    consent_token => $token  # required
    return_url    => $url,   # optional
  );
}

refresh_url

Generates a URL used for refreshing consent.

my $url = $client->refresh_url(
  consent_token => $token,  # required
  return_url    => $url,    # optional
);

AUTHOR

Andrew M. Jenkinson <jenkinson@cpan.org>

LICENSE AND COPYRIGHT

Copyright 2008-2011 Andrew M. Jenkinson.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

DEPENDENCIES

LWP::UserAgent Crypt::Rijndael Digest::SHA MIME::Base64 Carp

SEE ALSO

WWW::Live::Contacts

LWP::UserAgent

API Errors<http://msdn.microsoft.com/en-us/library/cc287686.aspx>