README
1NAME
2 Yahoo::BBAuth - Perl interface to the Yahoo! Browser-Based
3 Authentication.
4
5SYNOPSIS
6 my $bbauth = Yahoo::BBAuth->new(
7 appid => $appid,
8 secret => $secret,
9 );
10 # Get your appid and secret by registering your application here:
11 # https://developer.yahoo.com/wsregapp/index.php
12 # Create an authentication link
13 printf '<a href="%s">Click here to authorize</a>', $bbauth->auth_url;
14 # You can include some application data or return a user hash using optional params:
15 printf '<a href="%s">Click here to authorize</a>', $bbauth->auth_url(
16 send_userhash => '1',
17 appdata => 'someappdata',
18 );
19 # After the user authenticates successfully, Yahoo returns the user to the page you
20 # dictated when you signed up. To verify whether authentication succeeded, you need to
21 # validate the signature:
22 if (!$bbauth->validate_sig()) {
23 print '<h2>Authentication Failed. Error is: </h2>'.$bbauth->{sig_validation_error};
24 exit(0);
25 }
26 # You can then make an authenticated web service call on behalf of the user
27 # For Yahoo! Mail:
28 my $json = $bbauth->make_jsonrpc_call('ListFolders', [{}] );
29 if (!$json) {
30 print '<h2>Web services call failed. Error is:</h2> '. $bbauth->{access_credentials_error};
31 exit(0);
32 }
33 # For Yahoo! Photos:
34 my $url = 'http://photos.yahooapis.com/V3.0/listAlbums?';
35 my $xml = $bbauth->auth_ws_get_call($url);
36 if (!$xml) {
37 print '<h2>Web services call failed. Error is:</h2> '. $bbauth->{access_credentials_error};
38 exit(0);
39 }
40
41DESCRIPTION
42 This module priovides an Object Oriented interface for Yahoo!
43 Browser-Based Authentication.
44
45 This module is ported from the official PHP class which is located on
46 this page: http://developer.yahoo.com/php
47
48METHODS
49 new(appid => $appid, secret => $secret)
50 Returns an instance of this module. You must set the your application id
51 and shared secret.
52
53 auth_url(%param)
54 Create the Login URL used to fetch authentication credentials. This is
55 the first step in the browser authentication process.
56
57 You can set the %param to send_userhash and appdata if you
58 need(optional).
59
60 The appdata typically a session id that Yahoo will transfer to the
61 target application upon successful authentication.
62
63 If send_userhash set, the send_userhash=1 request will be appended to
64 the request URL so that the userhash will be returned by Yahoo! after
65 successful authentication.
66
67 validate_sig
68 Validates the signature returned by Yahoo's browser authentication
69 services.
70
71 Returns false if the sig is invalid. Returns 0 if any error occurs. If 0
72 is returned, $self->sig_validation_error should contain a string
73 describing the error.
74
75 auth_ws_get_call($url)
76 Make an authenticated web services call using HTTP GET. Returns response
77 if successful, a string is returned containing the web service response
78 which might be XML, JSON, or some other type of text. If an error
79 occurs, 0 is returned, and the error is stored in
80 $self->access_credentials_error.
81
82 auth_ws_post_call($url)
83 Make an authenticated web services call using HTTP POST.
84
85 make_jsonrpc_call($method, $params)
86 Make an authenticated web services JSON-RPC call.
87
88 sig_validation_error
89 The error message when validate_sig fails.
90
91 access_credentials_error
92 The error message when auth_ws_get_call or auth_ws_post_call fail.
93
94ACCESSORS
95 appid
96 secret
97 userhash
98 appdata
99 timeout
100 token
101 WSSID
102 cookie
103
104AUTHORS
105 Jiro Nishiguchi E<lt>jiro@cpan.orgE<gt>
106 Jason Levitt E<lt>jlevitt@yahoo-inc.comE<gt>
107
108 This library is free software; you can redistribute it and/or modify it
109 under the same terms as Perl itself.
110
111SEE ALSO
112 * http://developer.yahoo.com/auth/
113
114