1

所以,我想使用 Plus.me 或者说 userinfo.profile 范围与 Google Cloud Endpoints 和 python 作为后端。

服务器配置:

            @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):

有人知道如何从 android 客户端发送适当的范围吗?我所知道的关于设置 android 客户端的是:

安卓客户端配置:

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);

因此,使用此配置不起作用。get_current_user() 返回 None 并且服务器日志中有错误:

“Oauth 框架用户与 oauth 令牌用户不匹配。”

如果我删除“ https://www.googleapis.com/auth/plus.me ”范围,则 get_current_user() 返回用户。

这件事是意料之中的,因为我没有从 android 客户端为此范围或范围本身提供令牌。那么,我怎样才能让它工作呢?我需要在android 客户端中进行哪些更改?

4

0 回答 0