gapi.analytics.auth.isAuthorized 在页面加载时始终为 false
gapi.analytics.auth.isAuthorized is always false on page load
我正在使用 gapi.analytics 嵌入 API,并且我正在 gapi.analytics.ready
函数中使用以下代码验证身份验证。
if (gapi.analytics.auth.isAuthorized()) {
onAuthorize();
} else {
gapi.analytics.auth.on('success', onAuthorize);
}
但是 gapi.analytics.auth.isAuthorized()
在页面加载时总是返回 false。
我该如何解决这个问题?
你可以这样做:
gapi.analytics.auth.on('needsAuthorization', function() {
console.log('User is not Authorized!');
});
When invoking the gapi.analytics.auth.authorize method, an initial check is made to see if the user is currently signed in. If the user is not signed in, this event is fired to indicate that further authorization is required.
我正在使用 gapi.analytics 嵌入 API,并且我正在 gapi.analytics.ready
函数中使用以下代码验证身份验证。
if (gapi.analytics.auth.isAuthorized()) {
onAuthorize();
} else {
gapi.analytics.auth.on('success', onAuthorize);
}
但是 gapi.analytics.auth.isAuthorized()
在页面加载时总是返回 false。
我该如何解决这个问题?
你可以这样做:
gapi.analytics.auth.on('needsAuthorization', function() {
console.log('User is not Authorized!');
});
When invoking the gapi.analytics.auth.authorize method, an initial check is made to see if the user is currently signed in. If the user is not signed in, this event is fired to indicate that further authorization is required.