Using the result from android AccountManager.getAuthToken via Zend_Gdata (401 unauthorized access)

I need to get an authentication token from an Android device (client side) using AccountManager.getAuthToken and then reuse it through Zend_Gdata (server side)

When using the 'cl' calendar, the authTokenType properties work as expected.

Android source:

String calendarToken = getAuthToken(account, 'cl' ... 

PHP source:

 $token = // value retrieved via Android 'calendarToken' $client = new Zend_Gdata_HttpClient; $client->setClientLoginToken($token); $gData = new Zend_Gdata($client); $feed = $gData->getFeed("http://www.google.com/calendar/feeds/default/private/full"); 

This works, however when using Gmail mail "authTokenType everything is not so smooth

Android source:

 String mailToken = getAuthToken(account, 'mail' ... 

PHP source:

 $token = // value retrieved via Android 'mailToken' $client = new Zend_Gdata_HttpClient; $client->setClientLoginToken($token); $gData = new Zend_Gdata($client); $feed = $gData->getFeed("https://mail.google.com/mail/feed/atom/"); 

This continues to throw a "Zend_Gdata_App_HttpException" with the message "Expected response code 200, received 401.

I tried to follow the guidelines for various google data APIs with no luck

+4
source share
1 answer

The only reason you should see the difference between AuthSub requests for the two services is the scope issue. Review the third number in the AuthSub docs and make sure that the token you are using has access to GMail.

0
source

All Articles