首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >安卓谷歌登录8月NeedPermission发行

安卓谷歌登录8月NeedPermission发行
EN

Stack Overflow用户
提问于 2014-06-22 14:23:55
回答 1查看 752关注 0票数 2

我现在要在我的应用程序中添加google登录。但是我得到了来自这个范围scope = "oauth2:" + Scopes.PLUS_LOGIN的令牌,但是服务器不能通过这个令牌获得用户的电子邮件。因此,我用一个空格添加了我的范围"https://www.googleapis.com/auth/userinfo.email“。但我只得到了一个系统错误。像这样

06-19 15:26:33.444 25229-25460/ System.err: com.google.android.gms.auth.UserRecoverableAuthException: NeedPermission 06-19 15:26:33.445 25229-25460/ W/System.err: at com.google.android.gms.auth.GoogleAuthUtil.getToken(Unknown Source) 06-19 15:26:33.447 25229-25460/ com.google.android.gms.auth.GoogleAuthUtil.getToken(Unknown来源)

我完全不明白我需要什么样的许可。这也是我的密码。

代码语言:javascript
复制
AsyncTask task = new AsyncTask() {
    @Override
    protected Object doInBackground(Object... params) {
        final String CLIENT_ID = "abc123.apps.googleusercontent.com";
        final List<String> SCOPES = Arrays.asList(new String[]{
            "https://www.googleapis.com/auth/plus.login",
            "https://www.googleapis.com/auth/userinfo.email"
        });
        try {
            String scopes = String.format("oauth2:server:client_id:%s:api_scope:%s", CLIENT_ID , TextUtils.join(" ", SCOPES));
            String token = GoogleAuthUtil.getToken(context, Plus.AccountApi.getAccountName(mGoogleApiClient), scopes);
            userInfo = new GoogleUserInfo(email, finalPersonPhotoUrl, currentPerson.getId(), token, currentPerson.getDisplayName());`enter code here`
        }
        catch (UserRecoverableAuthException e) {
            // This error is recoverable, so we could fix this
            // by displaying the intent to the user.
            e.printStackTrace();
        }
        catch (IOException e) {
            e.printStackTrace();
        }
        catch (GoogleAuthException e) {
            e.printStackTrace();
        }
        return null;
        }
    };
task.execute((Void) null);

我怎样才能通过电子邮件获得用户信息的令牌???

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-07-27 07:24:42

我尝试了很多方法,但我做不到,所以我收到了电子邮件,就像

代码语言:javascript
复制
String email = Plus.AccountApi.getAccountName(GoogleApiClient);

以及其他为用户提供的信息,您可以通过调用Plus.PeopleApi.getCurrentPerson获得所有这些信息。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24352211

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档