[英]gapi.auth.authorize with immediate: true is not working
I'm trying to do Gmail Oauth. 我正在尝试做Gmail Oauth。
When I call this function with immediate:true , still it's showing the popup window while authorizing. 当我用Instant:true调用此函数时,它仍在授权时显示弹出窗口。
Please let me know any mistake is there or not, also any alternative method. 请让我知道是否存在任何错误以及任何其他方法。
gapi.auth.authorize({client_id: clientId, scope: scopes, immediate: true}, callbackAuthResult);
Here's my Code: 这是我的代码:
function signin(getAuthStatus) {
gapi.auth.authorize({
'client_id': 'myID',
scope: 'email', immediate: true
},getAuthStatus);
}
function getAuthStatus() {
gapi.client.Myendpoint.MyEndpointMethod().execute(function (resp) {
console.log(resp);
}
First of all, We have to understand how oauth process works, 首先,我们必须了解oauth流程的工作原理,
In Google OAuth, 在Google OAuth中,
If immediate value is false , then browser will open up a popup, where people have to allow your application to get their details from Google. 如果即时值是false ,那么浏览器将打开一个弹出窗口,人们必须在其中允许您的应用程序从Google获取其详细信息。
If immediate value is true , then it'll be automatically authorized without any popup, where people don't have to allow the application. 如果即时值是true ,那么它将自动得到授权,而无需任何弹出窗口,而人们无需允许该应用程序。
Keep immediate value as false , while you are asking user to login to your application for the first time, then browser will open up popup and user will allow your application to get details. 将立即值保留为false ,当您要求用户首次登录您的应用程序时,浏览器将打开弹出窗口,并且用户将允许您的应用程序获取详细信息。 From next time onwards, wherever you are using OAuth to make authenticated calls in your application, put immediate value as true , because user already allowed your application, so you'll get user info directly without asking him for permissions again and again. 从下一次开始,无论您在哪里使用OAuth在应用程序中进行经过身份验证的调用,都应将即时值设置为true ,因为用户已经允许了您的应用程序,因此您将直接获得用户信息,而无需一次又一次地询问他的权限。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.