Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Google Sign-In now returning error popup_closed_by_user #506

Closed
sachinrekhi opened this issue Feb 9, 2019 · 46 comments
Closed

Google Sign-In now returning error popup_closed_by_user #506

sachinrekhi opened this issue Feb 9, 2019 · 46 comments

Comments

@sachinrekhi
Copy link

Our Electron desktop application has been using Google Sign-In for months now without any issues. But all of a sudden, starting today, Google Sign-In from our Electron desktop app started returning the "popup_closed_by_user" error. The login pop-up properly renders and you can successfully login to your Google account, but when the pop-up closes, instead of it properly logging in the user, it returns the popup_closed_by_user error.

Google Sign-In continues to work fine for our website from web browsers like Chrome, Safari, and Firefox, but no longer works from our Electron desktop app.

It appears there has been some kind of regression in the Google Sign-In service?

Our google auth code for reference:

var googleAuth

gapi.load('auth2', function() {
    googleAuth = gapi.auth2.init({
        client_id: 'XXX',
        scope: 'email profile',
        fetch_basic_profile: false
    })
})

function beginGoogleAuth() {
    googleAuth.grantOfflineAccess({
        prompt: 'select_account',
        redirect_uri: 'postmessage'
    }).then(function(response) {
        document.getElementById('login-google-auth-code').value = response.code
        document.getElementById('login-form').submit()
    })
}
@aabuhijleh
Copy link

I'm encountering the exact same issue with Electron. Working fine on Chrome.

@sachinrekhi
Copy link
Author

@grant looks like there was a regression in Google Sign-in recently. Seems somewhat similar to #473 in that it is only affecting certain clients like Electron, though the error in this case is different. Any chance you could ping the team to see if anything changed?

@JorgenPhi
Copy link

Same exact issue with Electron starting on Feb 6th. No changes were made to our end.

@grant
Copy link
Contributor

grant commented Feb 11, 2019

I do not seem to see recent changes to the gapi client.
Perhaps this is related: #405
Can you provide more details in the request and why Electron is making the request fail?

@josephfoulds
Copy link

Just like to chip in here and say we're experiencing the popup_closed_by_user error failure also in our React project - appears to be affecting a small % of users across a range of devices (Chrome, FireFox, Safari, Safari Mobile)

@bastienduran
Copy link

bastienduran commented Feb 12, 2019

Hi,

We do have the same issue. popup_closed_by_user error in our React/Electron project.
The same code works fine in Chrome, Safari and Firefox.

EDIT : this issue affects only users who have to signIn, already connected ones are not affected.

@rustemkk
Copy link

Hello,

Same for our project, React app running in electron gives popup_closed_by_user error. Web version is fine.

We use react-google-login and I was thinking maybe it has the issue, so I tried with simplest page with just google's suggested button and result is the same - working in browser, not working in electron.

@seamusml
Copy link

seamusml commented Feb 14, 2019

Hi, Also can report that this is no longer working for our electron app, but is working fine in any browser.

@JorgenPhi
Copy link

Any updates here? @grant

@grant
Copy link
Contributor

grant commented Feb 19, 2019

@JorgenPhi
I'm not sure why this is happening for this set of applications. I've stated that I believe there's no change in gapi that would cause this.

If there a specific something specific I can do, LMK. However, I cannot debug other projects that use this project like Electron.

@bastienduran
Copy link

@grant
Of course you can not debug other projects, bug as for @JorgenPhi, there were no modifications on the electron app.

@bodhi3032
Copy link

bodhi3032 commented Feb 19, 2019

@grant
Perhaps some more info will help:
I too am seeing this in my electron project. With no changes in our code, no changes to the electron base, our google authentication flow began failing and only giving a message of "popup_closed_by_user". We regressed against prior releases, also known to be previously working and found them to all fail the exact same way.

It is unlikely that this change is anything other than a change to the auth api given the steps we took to verify the issue and the google authentication being the only common factor.

Was something changed in policies? Is this a part/byproduct of the g+ shutdown (we are in the process of removing g+ for auth and profile info)?

Our project uses electron-prebuilt and was tested against 3.x and 4.x builds. All fail with the same error.

Apologies for the callout, we have thousands of users affected by this and having some support would be great.

@bodhi3032
Copy link

This may be related. Or not at all. Timeline coincides.

https://developers.google.com/terms/api-services-user-data-policy

@manelpb
Copy link

manelpb commented Feb 21, 2019

Any update about this issue? I'm also having the same problem

@grant
Copy link
Contributor

grant commented Feb 21, 2019

Note: I do not work on this library. I just work at Google and help all over.

I have notified the Google team this issue.
My unofficial guess is that G+ login/changes may be related.
I will report the answer I receive as soon as I get one from the gapi team.

@SatoshiOoO
Copy link

If what @bodhi3032 mentioned is true, then migrating to the alternative oauth scopes may help.

https://developers.google.com/identity/sign-in/web/quick-migration-guide

@sachinrekhi
Copy link
Author

@SatoshiOoO My app has always been using the alternative scopes and wasn't using the G+ scopes nor the G+ specific APIs, but instead the generic Google Sign-In APIs which haven't been deprecated. This issue is also only affecting our Electron app, but not our website login which continues to work fine.

The issue may definitely still be the result of an inadvertent change made alongside the G+ login/changes, but not likely due to lack of a migration needed on our side.

@bodhi3032
Copy link

I'd generally agree with @sachinrekhi that this is not g+ shutdown related, as our web (which also uses g+) still works.

Also if you check G's own docs, you'll find there appears to have issues as well: https://developers.google.com/identity/protocols/OAuth2UserAgent

Click the demo link, you'll see the auth is busted there.

So i think this is a policy issue, perhaps G itself didn't realize the full ramifications of the last updates. My guess is it may have to do with this (from the policy update link i posted earlier):

All permission requests must accurately represent the identity of the application that seeks access to user data. If you have obtained authorized client credentials to access Google API Services, keep these credentials confidential.

Whoever initially set this up on our project did so for web, and indeed the electron app follows the browser flows but using electron generated windows, though it does handle via the website (anyone else find this stuff overly convoluted at times?). I am wondering if perhaps something in this flow is failing the above criteria of accurately representing the app.

Which brings back to the gapi side of things: The broken auth on G's docs page at least gives an error that is useful(ish). perhaps gapi needs an update to do the same, rather than the generic error we are all receiving.

My next step is to look at migrating to the Desktop Flow for oauth. I'm curious if others affected here used the web browser flow or desktop, or some variation thereof?

Best of luck everyone, I will post back my results when I have some.

@sachinrekhi
Copy link
Author

@bodhi3032 I’m using the web browser flow in both our web client and Electron client. Can you link to the docs for the desktop flow?

@rustemkk
Copy link

OK, good news, looks like they fixed the problem, now it works as expected with no changes on our side. Check your apps ;-)

@aabuhijleh
Copy link

I can confirm it's working now in our Electron app.

@bastienduran
Copy link

Same for us. Great news !!

@manelpb
Copy link

manelpb commented Feb 25, 2019

Same here! \o/

@seamusml
Copy link

Same, Thanks for the fix!!

@sachinrekhi
Copy link
Author

I can also confirm that Google login is once again working in our Electron app without any required changes. Thanks so much!

@bodhi3032
Copy link

While it's nice that all is working again, the fact it went down and there was no acknowledgement of the issue or report of findings is troublesome.

I for one will be looking to adapt user flows to mitigate such outages, but the trade off is more friction in the sign up process.

Keeping the devs who use such platforms in the loop is important in maintaining trust and building community support.

But hurrah? i guess..

@sebastialonso
Copy link

I think it came back. I'm experiencing the same issue in Brave browser, but not in Chrome not Firefox.
Seems suspicious...

@jimmityglick
Copy link

i get this issue today using Chromium - Version 76.0.3809.100

@IstvanD
Copy link

IstvanD commented Dec 6, 2019

The error is present on Version 78.0.3904.108 (Official Build) (64-bit)

@tomnielsen
Copy link

OK. I was hitting this issue and realized the bug might be in the original code.

Anyone care to verify this address the error?

Original:

var googleAuth

gapi.load('auth2', function() {
    googleAuth = gapi.auth2.init({
        client_id: 'XXX',
        scope: 'email profile',
        fetch_basic_profile: false
    })
})

function beginGoogleAuth() {
    googleAuth.grantOfflineAccess({
        prompt: 'select_account',
        redirect_uri: 'postmessage'
    }).then(function(response) {
        document.getElementById('login-google-auth-code').value = response.code
        document.getElementById('login-form').submit()
    })
}

Fix is to use the .catch() NOT a try{}catch around the call.

var googleAuth

gapi.load('auth2', function() {
    googleAuth = gapi.auth2.init({
        client_id: 'XXX',
        scope: 'email profile',
        fetch_basic_profile: false
    })
})

function beginGoogleAuth() {
    googleAuth.grantOfflineAccess({
        prompt: 'select_account',
        redirect_uri: 'postmessage'
    }).then(function(response) {
        document.getElementById('login-google-auth-code').value = response.code
        document.getElementById('login-form').submit()
    }).catch(function(error) {
      console.log(error)
    })
}

@KSVarun
Copy link

KSVarun commented May 29, 2020

Hi All,
I am facing similar issue, any help would be really helpful. I am a junior developer and I might be doing it wrong.

I have a react app, when run locally everything works fine but when I build the project using "yarn build" and move the contents of build folder to aws s3 bucket and enable static hosting, it fails and says "popup_closed_by_user".

I have made sure all the necessary URL have been whitelisted in the oauth credentials side. But still it says that s3 bucker URL is not whitelisted.

Thanks in advance.

@wrksp-andreas
Copy link

Seems to be happening again. Same symptoms as listed previously. Everything works fine in chrome, but is busted in electron.

@imvenky
Copy link

imvenky commented Jul 20, 2020

Hey, I'm also facing the same issue, it works in my machine but not working in my colleague's machine, please help me to fix this.

@edouardmercier
Copy link

For those still struggling with the popup_closed_by_user issue on Electron, just to let you know that in order to fix this issue, you need to set the BrowserWindow.webPreferences.nativeWindowOpen property to true (this is required from Electron v8.2.4) on the window which hosts the Google sign-in button.

@IbrahimShamma99
Copy link

It also happens in React App all browsers with me

@macgill4444
Copy link

@edouardmercier thank you so much! That fixed the issue for us on electron!

@Neeraj7668
Copy link

I'm also facing the same issue with Electron. Working fine on Chrome.

@afrieirham
Copy link

For those still struggling with the popup_closed_by_user issue on Electron, just to let you know that in order to fix this issue, you need to set the BrowserWindow.webPreferences.nativeWindowOpen property to true (this is required from Electron v8.2.4) on the window which hosts the Google sign-in button.

I can verify this works, thank you for this 👍

@jhkcia
Copy link

jhkcia commented Feb 18, 2022

thanks @edouardmercier

@maradanasai
Copy link

maradanasai commented Apr 5, 2022

I'm getting this error even in chrome if I login in incognito tab. I'm using the following code

<script src="https://apis.google.com/js/client:platform.js?onload=renderButton" async defer></script>
    <script>
        function renderButton() {
            gapi.load('auth2', function () {
                auth2 = gapi.auth2.init({
                    client_id: 'xxxxx',
                    scope: 'profile email',
                });
            });
        }
    </script>
.............
..............
function onSuccess(result) {
        console.log(result);

        authenticate(result.code)
            .then(res => {
                token = res.data.token;
                console.log(res);
            })
            .catch(console.log);
    }

    function authenticate(code) {
        return axios.post('http://localhost:8080/auth/google', JSON.stringify({code}));
    }
    .............
 function onClickSignIn() {
        auth2.grantOfflineAccess()
            .then(onSuccess)
            .catch(onFailure);
    }   

@bedamatta05
Copy link

Facing the same issue in react app in all browser. Someone please help.

@dvanderb
Copy link
Collaborator

For authentication/authorization issues please note that gapi.auth2 has been deprecated and replaced with Google Identity Services. See https://developers.googleblog.com/2021/08/gsi-jsweb-deprecation.html for more information. If you have questions related to authentication/authorization please look at the associated documentation or post questions on Stack Overflow with the google-oauth tag.

@Neeraj7668
Copy link

Neeraj7668 commented May 21, 2022 via email

@bedamatta05
Copy link

bedamatta05 commented May 21, 2022 via email

@Neeraj7668
Copy link

Neeraj7668 commented May 24, 2022 via email

@Neeraj7668
Copy link

Neeraj7668 commented Oct 11, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests