klenwell information services : GreqoDocRequestGoogleToken

Revision [216]

This is an old revision of GreqoDocRequestGoogleToken made by KlenwellAdmin on 2007-02-21 14:14:27.
For the new Blogger Data 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. If the account settings are properly set in blogger_data.inc.php, the function greqo_request_clientlogin_token will request and store a token for use with any Blogger API requests.

Sample Code

if ( greqo_request_clientlogin_token($GREQO['BLOGGER']['user'], $GREQO['BLOGGER']['password'], 'blogger', 1) )
  $_FLAG['gdata_auth_ok'] = 1;
  trigger_error('google authentication failed.  make sure you have the correct account settings in blogger_data.inc.php and check the status of your blogger account', E_USER_WARNING);


string greqo_request_clientlogin_token ( string user name, string password, string Google service[, int force] )

This function 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'] where it will be accessible as a global variable to other functions that require it within the library.


Old Blogger accounts used basic authentication to authenticate users. According to the Blogger Data API, this authentication method should now work with old Blogger Accounts. However, I have not successfully authenticated an old Blogger account with this method. Meanwhile, as of this writing, basic authentication still works (see lastgoogle.blogspot.com).

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.