How can Firebase + Google OAuth be configured with a specific “hd” (hosted domain) parameter?

大城市里の小女人 提交于 2020-01-12 05:40:06

问题


I'm using Firebase with the Google authentication provider.

When using Google OAuth in other applications, I'm able configure authentication to be restricted to specific domains.

The Google OpenID Connect documentation details the "hd" parameter which is used for this functionality. https://developers.google.com/identity/protocols/OpenIDConnect#hd-param

How can this be configured for Firebase?


回答1:


With the new setCustomParameters function, you can add the hd parameter

var provider = new firebase.auth.GoogleAuthProvider();
provider.addScope('email');
provider.setCustomParameters({
    'hd': 'uw.edu'
});
firebase.auth().signInWithRedirect(provider);

Here is the API Doc https://firebase.google.com/docs/reference/js/firebase.auth.GoogleAuthProvider#setCustomParameters

Requires at least Firebase Version 3.5.0 - October 14, 2016. https://firebase.google.com/support/release-notes/js



来源:https://stackoverflow.com/questions/34689734/how-can-firebase-google-oauth-be-configured-with-a-specific-hd-hosted-domai

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