How to add more scopes in GoogleCloud Endpoints

牧云@^-^@ 提交于 2019-12-08 09:21:30

问题


So, I want to use Plus.me or lets say userinfo.profile scope with Google Cloud Endpoints with python as a backend.

Server Configuration:

            @endpoints.api( name='sidebar', version='v1',# auth=AUTH_CONFIG,
            allowed_client_ids=[WEB_CLIENT_ID,
                                ANDROID_CLIENT_ID,
                                endpoints.API_EXPLORER_CLIENT_ID],
            audiences=[ANDROID_AUDIENCE],
            scopes=[endpoints.EMAIL_SCOPE, "https://www.googleapis.com/auth/plus.me"])
            class Sidebar(remote.Service):

Does anybody have an idea how to send the appropriate scope from android client? All I know about setting up the android client is:

Android Client Configuration:

String WEB_CLIENT_ID = "xxxxxxxxxx-bbbbbbbbbbbbbbbbbbbbbbbbb.apps.googleusercontent.com";
GoogleAccountCredential credential = GoogleAccountCredential.usingAudience(
            mContext, AUDIENCE);

credential.setSelectedAccountName(accountName);
Sidebar.Builder api = new Sidebar.Builder(AndroidHttp.newCompatibleTransport(), new GsonFactory(), credential);
api.setRootUrl(mRootUrl);

So, using this configuration doesnt work. get_current_user() returns None and there is an error in the server logs:

"Oauth framework user didn't match oauth token user."

If I remove the "https://www.googleapis.com/auth/plus.me" scope then the get_current_user() returns the user.

This thing is expected as I am not supplying a token for this scope or the scope itself from android client. So, How can I get this working? What changes do I need to do in the android client?

来源:https://stackoverflow.com/questions/32882569/how-to-add-more-scopes-in-googlecloud-endpoints

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!