简体   繁体   English

带立即数的gapi.auth.authorize:true不起作用

[英]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.

相关问题 为什么带有“ immediate:false”的gapi.auth.authorize不关闭弹出窗口并触发回调? - Why gapi.auth.authorize with “immediate: false” doesn't close popup and fire callback? gapi.auth.authorize:TypeError:cv(...)为null - gapi.auth.authorize: TypeError: cv(…) is null gapi.auth.authorize:TypeError:_.Uu不是函数 - gapi.auth.authorize: TypeError: _.Uu is not a function 使用gapi.auth.authorize时访问被拒绝错误 - Access Denied Error when using gapi.auth.authorize 检测用户在使用gapi.auth.authorize时是否关闭弹出窗口 - Detect if user closes popup when using gapi.auth.authorize 如何将login_hint传递给gapi.auth.authorize? - How do I pass login_hint to gapi.auth.authorize? Google OAuth gapi.auth.authorize X-Frame-Options:SAMEORIGIN - Google OAuth gapi.auth.authorize X-Frame-Options: SAMEORIGIN 对于 javascript 调用 api “gapi.auth.authorize” 的 google 分析没有得到执行。 - For javascript the call to api “gapi.auth.authorize” for google analytics not getting executed. 在node-webkit应用程序上通过Google登录时,不会调用gapi.auth.authorize回调 - gapi.auth.authorize callback doesn't get called when doing sign-in via Google on node-webkit app Gapi auth2 未定义 - Gapi auth2 is undefined
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM