gpt4 book ai didi

android - Google 用户信息仅通过来自 android google plus 的访问 token 提供 id

转载 作者:行者123 更新时间:2023-11-30 03:09:10 28 4
gpt4 key购买 nike

我使用 Google Plus SDK 登录。如果成功,我请求用户的访问 token

String scope = "oauth2:" + Scopes.PLUS_LOGIN + " " + Scopes.PLUS_PROFILE;
String token = GoogleAuthUtil.getToken(context, mPlusClient.getAccountName(), scope);

它有效并且我得到了 token ,但是当我尝试它时(我会将 token 发送到服务器)我得到了这个:

https://www.googleapis.com/oauth2/v1/userinfo?access_token=ya29.xxx ...

{ id: "1060xxxxxxxxxxxxxx" }

其他数据在哪里,例如电子邮件、姓名等???

我尝试了另一个解决方案并将服务器部分添加到范围:

String CLIENT_ID = "abc123.apps.googleusercontent.com";
List<String> SCOPES = Arrays.asList(new String[]{
"https://www.googleapis.com/auth/plus.login",
"https://www.googleapis.com/auth/plus.me"
});

String scope = String.format("oauth2:server:client_id:%s:api_scope:%s", CLIENT_ID, TextUtils.join(" ", SCOPES));

但在这种情况下我总是会出错:

com.google.android.gms.auth.GoogleAuthException: Unknown
at com.google.android.gms.auth.GoogleAuthUtil.getToken(Unknown Source)

最佳答案

此处记录了完整的 Google+ 范围:https://developers.google.com/+/api/oauth#scopes

您还可以使用 OAuth Playground :https://developers.google.com/oauthplayground/探索其他 Google 服务使用的范围

关于android - Google 用户信息仅通过来自 android google plus 的访问 token 提供 id,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21283289/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com