简体   繁体   中英

gapi.auth.authorize with immediate: true is not working

I'm trying to do Gmail Oauth.

When I call this function with immediate:true , still it's showing the popup window while authorizing.

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,

In 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.

If immediate value is true , then it'll be automatically authorized without any popup, where people don't have to allow the application.

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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM