You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 18, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Apr 18, 2026. It is now read-only.
popup_closed_by_user thrown when calling signIn in Chrome #405
From all of the browsers I've tested, this only seems to occur on Chrome, both incognito and in an authenticated browser. First, I check if the gapi object is properly authenticated. If not, I call the signIn method to authenticate. If the browser is not authenticated, the popup works as intended and I am able to sign in and then the signIn promise resolves. However, if the browser is already linked to a Google account, the popup opens and immediately closes (I assume this is because it is trying to use the authenticated account). This causes the popup_closed_by_user exception to be thrown and the gapi object is never authenticated. Below is the code.
const auth = gapi.auth2.getAuthInstance();
if (!auth.isSignedIn.get()) {
auth.signIn().then(() => // Do the thing);
} else {
// Do the thing
}
Reacted by Dustin Kerstein, mike-seekwell, Rohit Khatri, razakadam74 and Valeriy Borodayev
Yes. Though it is through a Vue Store action. So, I'm not sure if that would affect anything.
Additionally, I'm not sure this is 100% related, but it seems as though the gapi object has trouble authenticating through cookies on Chrome. On Opera, once I authenticate, the gapi object says its authenticated until I explicitly sign out of the Google account, even persisting through different tabs of the same origin. Now that I think about it, this makes sense and is definitely the desired outcome. Any thoughts on why this wouldn't be working the same in Chrome?
Not sure if you guys pushed a fix, but I can't seem to reproduce on my 64-bit version of Chrome. It is interesting to note that I originally encountered the issue using a 64-bit version of Chrome, and I was able to consistently reproduce it until today. I would test on 32-bit, but since 32-bit Chrome is deprecated on Ubuntu, that's a bit more difficult for me to test.
@sugarmanz thanks for the update. It seems that the 32-bit issue that @wjf444128852 observes might be due to a different browser configuration (not the fact it's 32-bit) as we are discussing in another thread.
Let me know if you observe again the issue @sugarmanz!
Thanks a lot.. Because the setting about chrome://settings/content/cookies of the Chrome 32-bit on ensure that "Block third-party cookies" option is enabled !!!!
@lopugit I saw similar issues earlier on some other websites. I could even reproduce it with single user. But it seems the issue is gone now. Are you still experiencing this issue?
Having this issue as well. Chrome 67.0.3396.99 (Official Build) (64-bit) on OS X 10.11.6. Just copy-pasting the code from the Building a button with a custom graphic sample and swapping in my own client ID is enough to trigger it. I think I'm even having the same issue with the sample mentioned above, but there's no error message to test it.
Block Third Party Cookies is disabled. It works without issue when I'm in incognito mode. I went onto a computer I hadn't used before and it worked there as well. It seems like it maybe has something to do with Chrome knowing the login email address already?
If I'm logged into my Google account and I try to use the sign-in button, the sign-in window flashes up for a split second, closes, and I get the popup_closed_by_user error alert. If I'm not logged into my account, the window comes up, asks me for my username and password, and then closes and I get the same error.
Not seeing any issues in Safari.
Edited to mention: this is only happening on one of my computers. The computer where it's working is running the same Chrome version but OS X 10.13.5. It also only started not working on my other computer today. I was logged into the same site yesterday with no issues.
Simply Enable the cookies. it solved the issue for me
Having this issue as well. Chrome 67.0.3396.99 (Official Build) (64-bit) on OS X 10.11.6. Just copy-pasting the code from the Building a button with a custom graphic sample and swapping in my own client ID is enough to trigger it. I think I'm even having the same issue with the sample mentioned above, but there's no error message to test it.
Block Third Party Cookies is disabled. It works without issue when I'm in incognito mode. I went onto a computer I hadn't used before and it worked there as well. It seems like it maybe has something to do with Chrome knowing the login email address already?
If I'm logged into my Google account and I try to use the sign-in button, the sign-in window flashes up for a split second, closes, and I get the popup_closed_by_user error alert. If I'm not logged into my account, the window comes up, asks me for my username and password, and then closes and I get the same error.
Not seeing any issues in Safari.
Edited to mention: this is only happening on one of my computers. The computer where it's working is running the same Chrome version but OS X 10.13.5. It also only started not working on my other computer today. I was logged into the same site yesterday with no issues.
Simply Enable the cookies. it solved the issue for me
But what if the user of your app decides to block third party cookies?
EDIT: About 20 minutes later it started working. The client ID and developer dashboard configuration for my app was brand new, perhaps it needed to percolate into a database somewhere?
Version 93.0.4577.82 (Official Build) (64-bit). popup_closed_by_user occured only in debug mode of VSC, stand-alone Chrome and Edge are all fine. Removing all account from Chrome works.
Activity
TMSCH commentedon Mar 5, 2018
Hi @sugarmanz, is this snippet called after a user clicks a button?
sugarmanz commentedon Mar 5, 2018
Yes. Though it is through a Vue Store action. So, I'm not sure if that would affect anything.
Additionally, I'm not sure this is 100% related, but it seems as though the
gapiobject has trouble authenticating through cookies on Chrome. On Opera, once I authenticate, thegapiobject says its authenticated until I explicitly sign out of the Google account, even persisting through different tabs of the same origin. Now that I think about it, this makes sense and is definitely the desired outcome. Any thoughts on why this wouldn't be working the same in Chrome?TMSCH commentedon Mar 6, 2018
What version of Chrome are you using? Are you blocking third-party cookies?
sugarmanz commentedon Mar 6, 2018
I am not blocking third-party cookies. And my Chrome version is:
64.0.3282.140 (Official Build) (64-bit)TMSCH commentedon Mar 7, 2018
Would you have a public app I could try? Or a full snippet of code?
TMSCH commentedon Mar 7, 2018
Alternatively, can you check with the same setup than you have, the button here: https://developers.google.com/identity/sign-in/web/sign-in#add_a_google_sign-in_button. See if it changes from "Sign in" to "Signed in". Thanks!
emhagman commentedon Mar 12, 2018
This is also occurring for me. If you open a new tab on Chrome, the issue goes away. If you refresh the same page, the issue remains.
TMSCH commentedon Mar 12, 2018
@emhagman can you reproduce the issue in the link I gave?
jiucheng-front commentedon Mar 21, 2018
I got the same problem ,this example online.
Clicking Google sign in and Google sign out will works on any browser.
https://wjf444128852.github.io/demo01/login/
jiucheng-front commentedon Mar 21, 2018
@TMSCH https://wjf444128852.github.io/demo01/login/
jiucheng-front commentedon Mar 21, 2018
@TMSCH This error will only appear on 32-bit chrome
TMSCH commentedon Mar 28, 2018
@wjf444128852 interesting, that's valuable information. I will see if I can get reproduce on a 32-bit Chrome.
sugarmanz commentedon Mar 29, 2018
Not sure if you guys pushed a fix, but I can't seem to reproduce on my 64-bit version of Chrome. It is interesting to note that I originally encountered the issue using a 64-bit version of Chrome, and I was able to consistently reproduce it until today. I would test on 32-bit, but since 32-bit Chrome is deprecated on Ubuntu, that's a bit more difficult for me to test.
TMSCH commentedon Mar 29, 2018
@sugarmanz thanks for the update. It seems that the 32-bit issue that @wjf444128852 observes might be due to a different browser configuration (not the fact it's 32-bit) as we are discussing in another thread.
Let me know if you observe again the issue @sugarmanz!
jiucheng-front commentedon Mar 30, 2018
Thanks a lot.. Because the setting about chrome://settings/content/cookies of the Chrome 32-bit on ensure that "Block third-party cookies" option is enabled !!!!
@TMSCH @sugarmanz
10 remaining items
lopugit commentedon Oct 17, 2018
I tested in incognito mode and single user works, multi breaks, on
SatoshiOoO commentedon Oct 17, 2018
@lopugit I saw similar issues earlier on some other websites. I could even reproduce it with single user. But it seems the issue is gone now. Are you still experiencing this issue?
kongguibin commentedon Oct 17, 2018
We submitted a fix for the 'popup_closed_by_user' error. Please verify the bug is fixed.
vamshikilari commentedon Nov 30, 2018
Simply Enable the cookies. it solved the issue for me
wichopy commentedon Nov 30, 2018
But what if the user of your app decides to block third party cookies?
yoyoyvr commentedon Dec 4, 2018
I'm having this problem too. Chrome 70.0.3538.102 (Official Build) (64-bit) on Windows 7.
EDIT: About 20 minutes later it started working. The client ID and developer dashboard configuration for my app was brand new, perhaps it needed to percolate into a database somewhere?
IstvanD commentedon Dec 6, 2019
The error is present on Version 78.0.3904.108 (Official Build) (64-bit)
StasUshomirsky commentedon Sep 28, 2020
This error is still present in Version 85.0.4183.121 (Official Build) (64-bit)
omar-dulaimi commentedon Oct 24, 2020
Still occurring in Version 85.0.4183.83 (Official Build) (64-bit)
tmasrat commentedon Oct 26, 2020
I am on version 86.0.4240.111 (Official Build) (64-bit) and it's still happening
pexak commentedon Dec 12, 2020
Started working on Version 87.0.4280.88
TLKG commentedon Sep 21, 2021
Version 93.0.4577.82 (Official Build) (64-bit).
popup_closed_by_useroccured only in debug mode of VSC, stand-alone Chrome and Edge are all fine. Removing all account from Chrome works.namanbarkiya commentedon May 22, 2022
2022 update for React and JS!
Experienced the identical problem, and after trying numerous workarounds, realised that I was missing gapi initialization!
React:
install gapi-script
npm i gapi-scriptimport gapi from gapi-script
import { gapi } from "gapi-script";load gapi in App()
JS:
Hope the steps work for you ^_^
tungnguyenvan commentedon Jul 17, 2022
Thank you so much @naman9199, it work for me