-
Notifications
You must be signed in to change notification settings - Fork 21
Open
Description
I am using gapi-script to enable login with google in my react application. But when user logins in first time its fine but for subsequent login attempt google auto logins with the previous account that user selected. But I want to display the account selection prompt.
Where should I put the configuration, something line {prompt : "select_account"}
NOTE : This happens only when I have 1 account signed in into google, I have 2 more account added to google but signed out. I want the user to be able to see the account selection popup.

also posted here
import { gapi, loadAuth2 } from 'gapi-script';
let auth2;
export default function LoginForm() {
const setAuth2 = async () => {
auth2 = await loadAuth2(gapi, GOOGLE_CLIENT_ID, '');
if (auth2.isSignedIn.get()) {
updateUser(auth2.currentUser.get())
} else {
attachSignin(document.getElementById('google-login'), auth2);
}
}
useEffect(() => {
setAuth2();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
const updateUser = async (currentUser) => {
const email = currentUser.getBasicProfile().getEmail();
const image = currentUser.getBasicProfile().getImageUrl();
if (email) {
// got the email now logout
auth2.signOut().then(() => {
console.log('google signed out.');
});
// loginApi({ email, type: "google" });
}
};
const attachSignin = (element, auth2) => {
auth2.attachClickHandler(element, {},
(googleUser) => {
updateUser(googleUser);
}, (error) => {});
};
return (
<LoadingButton id="google-login">
Sign in with Google
</LoadingButton>
);
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels