I have a google login, and I'm getting this error {error: "popup_closed_by_user"}
Here is my code:
const startApp = () => {
gapi.load('auth2', function(){
auth2 = gapi.auth2.init({
client_id: 'CLIENT_ID',
cookiepolicy: 'single_host_origin',
})
auth2.signIn()
.then(function() {
console.log(auth2)
})
.catch(function(error){
console.log(error)
});
attachSignin(document.getElementById('google-button'));
});
};
I have seen answers saying that I need to separate the 'gaps.load' from the 'gap.auth2.init' but I get that there's an error on init because it's not defined. This code works and I'm able to sign in but I always get the popup of the "error: popup_closed_by_user"
Also, I don't have any ad-blockers and this error I get it on all devices and all browsers.
I have a google login, and I'm getting this error {error: "popup_closed_by_user"}
Here is my code:
const startApp = () => {
gapi.load('auth2', function(){
auth2 = gapi.auth2.init({
client_id: 'CLIENT_ID',
cookiepolicy: 'single_host_origin',
})
auth2.signIn()
.then(function() {
console.log(auth2)
})
.catch(function(error){
console.log(error)
});
attachSignin(document.getElementById('google-button'));
});
};
I have seen answers saying that I need to separate the 'gaps.load' from the 'gap.auth2.init' but I get that there's an error on init because it's not defined. This code works and I'm able to sign in but I always get the popup of the "error: popup_closed_by_user"
Also, I don't have any ad-blockers and this error I get it on all devices and all browsers.
Share edited Mar 14, 2019 at 18:47 MCM asked Mar 8, 2019 at 18:10 MCMMCM 1412 silver badges16 bronze badges 2- Have you managed to solve this? Thank you – Darkkz Commented Nov 13, 2019 at 11:54
- @Darkkz Found my solution here. stackoverflow./questions/47355520/… – Arthur Decker Commented Jan 31, 2020 at 20:38
2 Answers
Reset to default 5This issue happens for newly created google clientIDs. This fix worked for me by passing 'plugin_name' along with client ID. Otherwise we get the 'popup_closed_by_user' error no matter how many times you clear the cache and enable cookies.
The reason for this issue is given in here - developers.google.
In the above case we have to pass 'plugin_name' with client ID, to resolve the issue
auth2 = gapi.auth2.init({
client_id: 'CLIENT_ID',
cookiepolicy: 'single_host_origin',
plugin_name: 'hello' //any name can be used
})
Hope this helps.
This works like a charm, thanks @veena-k-suresh
As I researched further this is because "new Client IDs created before July 29th, 2022 can use the older Google Platform Library. By default, newly created Client IDs are now blocked from using the Platform Library and instead must use the newer Google Identity Services library"
Explanation here: https://developers.google./identity/sign-in/web/reference#gapiauth2clientconfig