Firebase - What this means to set custom parameters to provider?

天涯浪子 提交于 2021-01-29 02:14:39

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!