当使用Oauth2谷歌时,双倍请求权限。

问题描述 投票:0回答:1

我在使用 "client:auth2:analytics"(Google Authenticate & Analytics)时有个问题。当我选择一个账户进行验证后,在验证对话框上会出现一个对话框,要求用户允许应用的某些权限(见下图),如何才能自动允许所有权限?

  • 要求用户确认权限。

enter image description here

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

enter image description here

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();
};
javascript google-oauth google-analytics-api google-signin google-api-js-client
1个回答
0
投票

这种情况的发生是由于未经验证的域名。

所有你需要验证你的域名,并提供应用程序名称和网站地址在Oauth控制台。

© www.soinside.com 2019 - 2024. All rights reserved.