=====Greqo Docs : Requesting a Google Auth Token===== For Google Data services, like the new [[http://code.google.com/apis/gdata/blogger.html 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 [[http://code.google.com/apis/gdata/index.html GData API]]. The request_clientlogin_token method will request and store a token for use with any Blogger API requests. ====Sample Code==== %%(php) $GreqoBlogger = new GreqoBlogger($debug=1); $GreqoBlogger->email = 'user@gmail.com'; $GreqoBlogger->password = '*********'; if ( $GreqoBlogger->request_clientlogin_token($service='blogger', $force=1) ) { $_HTML['stdout'] .= '

token for user ' .$GreqoBlogger->email. ' retrieved

'; #$_HTML['stdout'] .= '

token: ' .$_SESSION['GDATA']['auth_token']. '

'; } else { $_HTML['stdout'] .= '

unable to retrieve authentication token (devs have been notified)

'; } %% ====Methods==== **string request_clientlogin_token( string Google service[, int force] )** This method requests an authentication token from the Google servers using the [[http://code.google.com/apis/accounts/AuthForInstalledApps.html 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 [[http://groups.google.com/group/bloggerDev/browse_frm/thread/f41921c75119f442 this post]]. ---- [[CategoryGreqo]]