"immediate_file" - could not automatically log in user

I had a problem when I developed my site using the Google+ login: I did step by step what the dock told me, but I always failed at step 4: https://developers.google.com/+/web/ signin /

the result was always “immediate” - it was not possible to automatically log into the user’s system, I just don’t know why, can someone help me, very thanks!

+11
source share
4 answers

Please note that in the sample code that you pointed to, the "immediate check" is checked. This is intentional, since the first time a user encounters a login button on a page, it does not work.

The reason this fails is because when the page loads first, before the user even clicks the button, a request is sent to Google to determine if the user has already been registered (for example, through Google or another site). If they are, they don’t need to log in again, so the button should never be displayed. But if they are already in not , you will get the answer "immediate_file" and you will either have to show (or not clear) the button.

tl; dr - Don't worry about not getting an immediate error the first time you load the page. This is normal.

+21

gapi.auth.authorize gapi.auth.signIn. :

gapi.auth.signIn({
    'callback': gPlusLoginCallback
});

function gPlusLoginCallback(authResult) {
    if (authResult['status']['signed_in']) {
        doSmth(authRes['access_token']); 
    } else if (authResult['error'] == "immediate_failed") {
        gapi.auth.authorize({
            client_id: gplusClientId,
            scope: 'https://www.googleapis.com/auth/plus.login email',
            immediate: true
        }, function (authRes) {
            if (authRes['status']['signed_in']) {
                doSmth(authRes['access_token']);
            }
        });
    }
}

function doSmth(accessToken){
    //Do smth
}
+3

": ", ": ". , https://developers.google.com/api-client-library/javascript/start/start-js. Google "gapi.auth.authorize({...", ": ", ": ".

+2
source

The question is old, but I recently ran into this problem.

In my case, it was because I pointed the URI parameter promptto none. I think Google does not like it if the user has never logged into your platform before.

Whenever I changed it to consentor completely deleted, it worked perfectly.

0
source

Source: https://habr.com/ru/post/1538861/


All Articles