2

In a deprecation announcement from Google, they say that developers need to migrate away from these scopes:

https://www.googleapis.com/auth/userinfo.email
https://www.googleapis.com/auth/userinfo.profile

and instead use these scopes:

email
profile

After doing so on my App-Engine backend, however, I'm having problems with my iOS app. On first run, it asks me to sign in and the screen shows both scopes correctly after which the app runs just fine. On the second run, where it is supposed to retrieve the authorization credentials from protected storage, it does not work as the App-Engine server is receiving null for the User parameter in the endpoint.

The App-Engine endpoint requires both the email and profile scope. The iOS code for retrieving previous credentials is:

GTMOAuth2Authentication* auth =
[GTMOAuth2ViewControllerTouch authForGoogleFromKeychainForName:AUTH_KEYCHAIN_NAME
                                                      clientID:Constants.IOS_CLIENT_ID
                                                  clientSecret:Constants.IOS_CLIENT_SECRET];

and the iOS code for authenticating should there be no previous credentials is:

viewController = [[GTMOAuth2ViewControllerTouch alloc]
                  initWithScope:Constants.EMAIL_SCOPE
                  clientID:Constants.IOS_CLIENT_ID
                  clientSecret:Constants.IOS_CLIENT_SECRET
                  keychainItemName:AUTH_KEYCHAIN_NAME
                  delegate:self
                  finishedSelector:@selector(viewController:finishedWithAuth:error:)];

This used to work just fine! Now the App-Engine server changed the email scope from .../userinfo.email to email and the profile scope from .../userinfo.profile to profile. The iPad app exhibits the same behavior against the new backend with Constants.EMAIL_SCOPE set to either value.

The google-api-objectivec-client library is v0510, the latest.

The Android version of my app continues to work just fine without any code changes after the backend change.

Update 2015-02-26: Now using r424 (2014-12-30) of google-api-objectivec-client. No change. If the AppEngine backend is using the new "profile" and "email" scopes, the iOS app cannot authenticate on the second (or later) run where it is loading the credentials from store rather than going through the sign-in flow.

The AppEngine log of the first (sign-in credentials) shows:

com.google.api.server.spi.auth.GoogleIdTokenUtils getCurrentUser: getCurrentUser: IdToken; email=testuser@gmail.com

The AppEngine log of the second (loaded credentials) shows:

com.google.api.server.spi.auth.AppEngineAuthUtils getCurrentUser: getCurrentUser: AccessToken; Tried and failed to get client id for scope 'com.google.api.server.spi.config.scope.DisjunctAuthScopeExpression@a015b54e'
com.google.appengine.api.oauth.InvalidOAuthParametersException: 
    at com.google.appengine.api.oauth.OAuthServiceImpl.makeSyncCall(OAuthServiceImpl.java:139)
    at com.google.appengine.api.oauth.OAuthServiceImpl.getGetOAuthUserResponse(OAuthServiceImpl.java:118)
    at com.google.appengine.api.oauth.OAuthServiceImpl.getAuthorizedScopes(OAuthServiceImpl.java:90)
    at com.google.api.server.spi.auth.AppEngineAuthUtils.getOAuth2AuthorizedScopes(AppEngineAuthUtils.java:140)
    at com.google.api.server.spi.auth.AppEngineAuthUtils.getCurrentUser(AppEngineAuthUtils.java:89)
    ...

This exception does not propagate up; null is returned for the user.

Is there something else that needs to be done for the GTMOAuth2ViewControllerTouch to work correctly with the new scopes? Or is there perhaps something wrong on the AppEngine side?

Brian White
  • 8,332
  • 2
  • 43
  • 67

0 Answers0