gpt4 book ai didi

android - 使用 G+ 登录 - 为什么范围 "plus.login"不能单独工作?

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:43:31 25 4
gpt4 key购买 nike

我已经看了几十个关于这个话题的答案,按照官方的快速入门指南,做了我能想到的一切。

我已经设置了我的谷歌开发者控制台的所有部分,包括为 OAuth 和公共(public) API 访问设置正确的调试 SHA1 key (甚至不知道是否有必要)。

问题

我在为我的 GoogleApiClient 设置范围时遇到问题。

googleClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(Plus.API)
.addScope(...)
.build();

我可以使用不同的范围组合登录:

            .addScope(new Scope("https://www.googleapis.com/auth/plus.login"))
.addScope(new Scope("https://www.googleapis.com/auth/plus.profile.emails.read"))
//WORKS! OR:

.addScope(Plus.SCOPE_PLUS_LOGIN) // == https://www.googleapis.com/auth/plus.login
.addScope(Plus.SCOPE_PLUS_PROFILE) // == https://www.googleapis.com/auth/plus.me
//WORKS! OR:

.addScope(new Scope("https://www.googleapis.com/auth/plus.profile.emails.read"))
//WORKS! OR:

.addScope(Plus.SCOPE_PLUS_PROFILE) // == https://www.googleapis.com/auth/plus.me
//WORKS!

它们都运行良好,我看到它们反射(reflect)在请求中(即,如果我设置 login + emails.read,对话框实际上会询问这两个) .

但是,我只需要“https://www.googleapis.com/auth/plus.login”。如果我只是设置 .addScope(new Scope("https://www.googleapis.com/auth/plus.login")) ,或者等效地, .addScope(Plus.SCOPE_PLUS_LOGIN) ,我遇到了 well-document Toast 错误:

Internal error occurred.

所以这个范围(我唯一需要的范围)与其他范围(例如 plus.me)一起工作,但不是单独使用。为什么会这样,我该怎么办?

最佳答案

您可以用以下对我有用的代码替换此代码。

   mGoogleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(Plus.API, Plus.PlusOptions.builder().build())
.addScope(Plus.SCOPE_PLUS_LOGIN).build();

关于android - 使用 G+ 登录 - 为什么范围 "plus.login"不能单独工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30247102/

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