Greqo Docs : Requesting a Google Auth Token
For Google Data services, like the new
Blogger API∞, any request or transaction must be accompanied by an authentication token set as a header for the request. This token must be requested using one of two methods promoted by Google as part of their
GData API∞. The request_clientlogin_token method will request and store a token for use with any Blogger API requests.
Sample Code
$GreqoBlogger = new GreqoBlogger($debug=1);
$GreqoBlogger->email = 'user@gmail.com';
$GreqoBlogger->password = '*********';
if ( $GreqoBlogger->request_clientlogin_token($service='blogger', $force=1) )
{
$_HTML['stdout'] .= '<p class="success">token for user ' .$GreqoBlogger->email. ' retrieved</p>';
#$_HTML['stdout'] .= '<p class="success">token: ' .$_SESSION['GDATA']['auth_token']. '</p>';
}
else
{
$_HTML['stdout'] .= '<p class="failure">unable to retrieve authentication token (devs have been notified)</p>';
}
Methods
string request_clientlogin_token( string Google service[, int force] )
This method requests an authentication token from the Google servers using the
ClientLogin interface∞
If the optional
force parameter is set to
0 and the token has already been requested, it will return the current token. If
force is set to
1, it will request a new token. The default is
1.
It returns the token itself as a string if the request is successful and 0 if it fails or there is an error. It also assigns the token to
$_SESSION['GDATA']['auth_token'] for reuse within the same session.
Notes
How often do you need to renew an authentication token? The answer seems to be: when in doubt, get a new token. See
this post∞.
CategoryGreqo
There are no comments on this page. [Add comment]