admin管理员组

文章数量:1415484

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);
}

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);
}
Share Improve this question asked Oct 27, 2015 at 6:49 Amaresh C.Amaresh C. 5995 silver badges17 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6

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.

本文标签: javascriptgapiauthauthorize with immediate true is not workingStack Overflow