I’m new with auth0 but very impressed so far. I use Google to login to my account with auth0. However once I login with Google once I dont get the ability to change which google account I wanna use. I also don’t see which google account I’m signing into. I saw some params you could enter to auth0.login() function but I never call that. Instead my call look like this (followed the quickstart guide):
auth0 = new auth0.WebAuth({
clientID: ‘xxxxxxxxxxx’,
domain: ‘xxxxxxxx.eu.auth0.com’,
responseType: ‘token id_token’,
audience: ‘https://xxxxxxxx.eu.auth0.com/userinfo’,
redirectUri: ‘http://localhost:3000/profile’,
scope: ‘openid profile email’
});
public login(): void {
this.auth0.authorize();
}
public handleAuthentication(): void {
this.auth0.parseHash((err, authResult) => {
if (authResult && authResult.accessToken && authResult.idToken) {
window.location.hash = '';
this.setSession(authResult);
this.router.navigate('/profile']);
} else if (err) {
this.router.navigate('/games']);
console.log(err);
}
});
}
I make the call in Angular4 if that matters! What and where do I need to add parameters to make the desired result? Thanks for a great service and thanks in advance for any answers.
1 Like
Taken from: oauth 2.0 - How to force account selection when using social provider login in Lock - Stack Overflow
When you use a social login provider the automatic sign-in is handled by the provider in question. Disabling the sso option and rememberLastLogin will mean Auth0 will not try to login you automatically or provide any information about who login for the last time.
When you login with Google the first time, Google created a session and next requests will automatically use that session by default.
However, Google supports an option that will allow you to choose the behavior you want, in this case it seems you want for the user to be able to select another account, which can be accomplished by passing the following option prompt=select_account
(see other options here) in the Google login request.
You can achieve this in Auth0 Lock by providing this option in the auth.params object. Updated example below:
var options = {
rememberLastLogin: false,
auth: {
sso: false,
redirect: false,
params: { prompt: 'select_account' }
}
};
var lock = new Auth0Lock('clientId', '[tenant].auth0.com', options);
Thanks that seems to be my desired result, however as of now I never instanciate an instance of "Auth0Lock. on my login metod I only call auth0.WebAuth.authorize(); and it directs the user to the login page and back. Should I refactor my code to use lock instead or can I get the desired result with the code I’m using?
In the angular sample project on the angular2+ quickstart they do it the way I have coded it without any auth0lock-instance.