无法请求范围https://www.googleapis.com/auth/plus.login

时间:2018-04-04 10:05:41

标签: javascript google-api google-oauth google-signin google-api-js-client

早上好,不确定这是否是正确的地方,但是在使用我们的安装屏幕时,oAuth窗口不断闪烁,我们向我们报告了几个问题。我们已经调试了这个尝试以获得许多范围,并将其缩小到范围:

https://www.googleapis.com/auth/plus.login

来自https://www.googleapis.com/discovery/v1/apis/drive/v3/rest的回复未返回我们要求的范围。

此前有效,但现在似乎造成了问题。你知道有什么改变可能会影响这个或者有什么简单的方法可以修复吗? 这是我获得范围和请求权限的号召:

  'apiKey': '---------',
    'discoveryDocs': [discoveryUrl],
    'clientId': '--------.apps.googleusercontent.com',
    'scope': SCOPE
}).then(function () {

    GoogleAuth = gapi.auth2.getAuthInstance();
    GoogleAuth.signOut();

// Listen for sign-in state changes.
    GoogleAuth.isSignedIn.listen(updateSigninStatus);

    // Handle initial sign-in state. (Determine if user is already signed in.)

    var user = GoogleAuth.currentUser.get();
    setSigninStatus();

});

在此过程的后期,我们检查用户现在是否获得了请求范围:

var user = GoogleAuth.currentUser.get();
var isAuthorized = user.hasGrantedScopes(SCOPE);

如果没有,我们会重新检查,以防获得权限延迟。

很抱歉,如果我还没有提供所有信息,如果您需要更多信息,请告知。

由于

2 个答案:

答案 0 :(得分:0)

让我们看看你的范围

googleapis.com/auth/userinfo.email 
googleapis.com/auth/userinfo.profile 
googleapis.com/auth/plus.me 
googleapis.com/auth/drive.readonly 
googleapis.com/auth/drive.apps.readonly 
googleapis.com/auth/drive 
googleapis.com/auth/plus.profile.agerange.read 
googleapis.com/auth/plus.profile.language.read

我不确定这是否是您问题的原因,但可能没有帮助 我认为你应该查阅范围页面here

googleapis.com/auth/drive.readonly 
googleapis.com/auth/drive.apps.readonly 
googleapis.com/auth/drive 

云端硬盘可让您访问View and manage the files in your Google Drive,这意味着两个只读的内容毫无意义。

这两个也是一样的

googleapis.com/auth/userinfo.profile 
googleapis.com/auth/plus.me 

相同
googleapis.com/auth/plus.login

您可以使用oauth playground来测试您是否有权访问所需内容。而不仅仅包括许多额外的范围。

答案 1 :(得分:0)

这看起来像谷歌的改变。

当您请求https://www.googleapis.com/auth/plus.login时,您现在实际收到了https://www.googleapis.com/auth/plus.me范围。

重现的步骤:

  1. 打开Google OAauth 2.0 Playground
  2. 请求https://www.googleapis.com/auth/plus.login范围并交换代码以获取访问令牌。
  3. 获取您的访问令牌并打开以下网址:https://www.googleapis.com/oauth2/v1/tokeninfo?alt=json&access_token= {your_token}
  4. 您现在收到以下范围:https://www.googleapis.com/auth/plus.me https://www.googleapis.com/auth/plus.profile.agerange.read https://www.googleapis.com/auth/plus.profile.language.read https://www.googleapis.com/auth/userinfo.profile
  5. 如果您检查https://www.googleapis.com/auth/plus.login,您的应用现已损坏。
  6. 这似乎是最近发生的(过去24小时内),因此可能是谷歌结束时的缺陷或一些无证的变更。

    我们通过对https://www.googleapis.com/auth/plus.me

    进行额外检查,在我们的应用中添加了变通方法

    希望这有帮助。

相关问题