问题
Currently i am working with firebase authentication. And found many of tutorials, they set custom parameters to provider like that
const provider = new firebase.auth.GoogleAuthProvider();
provider.setCustomParameters({ prompt: 'select_account' });
What this actually means setting custom parameters prompt
? Why we need to set custom parameters like that - in this case prompt: 'select_account'
?
回答1:
Read the API documentation for GoogleAuthProvider.setCustomParameters:
Sets the OAuth custom parameters to pass in a Google OAuth request for popup and redirect sign-in operations. Valid parameters include 'hd', 'hl', 'include_granted_scopes', 'login_hint' and 'prompt'. For a detailed list, check the Google documentation. Reserved required OAuth 2.0 parameters such as 'client_id', 'redirect_uri', 'scope', 'response_type' and 'state' are not allowed and will be ignored.
If you follow the link to the Google documentation, it says, for prompt
with value select_account
:
The authorization server prompts the user to select a user account. This allows a user who has multiple accounts at the authorization server to select amongst the multiple accounts that they may have current sessions for.
So, if you want the user to be able to choose from multiple Google accounts that they might have (instead of just the primary account), you should include this parameter.
来源:https://stackoverflow.com/questions/60493990/firebase-what-this-means-to-set-custom-parameters-to-provider