使用“ 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();
};
答案 0 :(得分:0)
这是由于未验证的域名引起的。
所有您需要验证的域名并在Oauth控制台中提供应用名称和网站地址