Search code examples
javajavascriptoauth-2.0google-appsgoogle-cloud-endpoints

Tried and failed to get client id for scope com.google.api.server.spi.config.scope.SingleAuthScopeExpression


In the Google Cloud Endpoints migration timetable, where steps to migrate from other authentication services are described, is written that https://www.googleapis.com/auth/userinfo.email scope is deprecated and the migration to email scope should be considered (analogically from userinfo.profile scope to profile scope).

In Java class Constants where are defined constants like Client ID for my @Api service classes, I changed

public static final String EMAIL_SCOPE = "https://www.googleapis.com/auth/userinfo.email";

to

public static final String EMAIL_SCOPE = "email";

Also on the client side in JavaScript example form google, I changed the scopes variable to

var scopes = 'email';

And in Google Developers Console logs I'm getting following exception:

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.SingleAuthScopeExpression@ed8e89a9'
com.google.appengine.api.oauth.InvalidOAuthParametersException: 
    at com.google.appengine.api.oauth.OAuthServiceImpl.makeSyncCall(OAuthServiceImpl.java:139)

In my endpoint method

@ApiMethod(name = "authorize", httpMethod="get")
    public AppUser authorize(User user) throws NonAuthorizedException {
        ...
    }

in the User user parameter a null is inserted by the Engine (I was authorized of course).

This doesn't work even if I change scope to profile. It only works only on localhost, but I think, it's not the problem.

One can ask, so why could you just let it be as userinfo.email? I was looking for some other scopes, because occasionally for some specific google users (I don't know what is specific about them), userinfo.email does't work either. Can anybody help me please? Thanks.


Solution

  • You don't need to update the scope. Even though the scope is deprecated, it's not going to be removed.