【问题标题】:Double request permission when using Oauth2 Google使用 Oauth2 Google 时的双重请求权限
【发布时间】:2019-10-03 14:40:24
【问题描述】:

我在使用“client:auth2:analytics”(Google Authenticate & Analytics)时遇到问题。在我选择一个帐户进行验证后,验证对话框上会出现一个对话框,要求用户允许应用程序的某些权限(请看下图),如何自动允许所有权限?

  • 请求用户确认权限。

  • 然后,仍然请求用户确认权限。

https://www.googleapis.com/auth/analytics https://www.googleapis.com/auth/analytics.readonly https://www.googleapis.com/auth/analytics.manage.users
this.onLoad = function () {
  const thiss = this;
  window.onload = function () {
     gapi.load('client:auth2:analytics', function () {
      gapi.client.init({
       'apiKey': thiss.config.apiKey,
       'clientId': thiss.config.clientId,
       'scope': thiss.config.scope,
      }).then(function () {

       thiss.handleBtnAuthClickStateful('reset');

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

       thiss.onAuthClick();
      });
     });
  }
}
this.onAuthClick = function () {
   const thiss = this;
   $(document).on('click', `#${thiss.html.btnAuthAnalytics}`, function () {
     thiss.handleOnAuthClick();
   });
};
this.handleOnAuthClick = function () {
  const thiss = this;

  if (!thiss.handleValidate()) {
    thiss.handleResetAuth();

    thiss.GoogleAuth.signIn().then(function () {
      if (thiss.GoogleAuth.isSignedIn.get()) {
        thiss.handleAfterSignIn();
      }
    });
  }
};
this.handleResetAuth = function () {
  const thiss = this;

  thiss.GoogleAuth.signOut();
  thiss.GoogleAuth.disconnect();
};

【问题讨论】:

  • 只有用户可以授权权限。您不能自动授权权限授予。域范围委派 (G Suite) 有一个例外,但我没有将这些令牌(从服务帐户创建)用于 Google Analytics。
  • 是的,但是现在,当用户单击身份验证按钮时,他们必须在两个屏幕上确认权限,我认为只需在一个屏幕上确认对用户更好,您可以再次查看我在主题中的更新。
  • Google 让用户分两步确认。这很好。我知道你无能为力。我更喜欢有点不便以获得更好的安全性。我希望谷歌在授权方面会变得更严格,而不是更宽松。您当然可以打开功能请求。
  • 非常感谢:D。

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


【解决方案1】:

这是由于域名未经验证。

您只需在 Oauth 控制台中验证您的域名并提供应用名称和网站地址

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-05
    • 1970-01-01
    • 2020-10-17
    • 2019-01-21
    相关资源
    最近更新 更多