我在使用 "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();
};
这种情况的发生是由于未经验证的域名。
所有你需要验证你的域名,并提供应用程序名称和网站地址在Oauth控制台。