如何使用特定的"hd"配置Firebase + Google OAuth? (托管域)参数? [英] How can Firebase + Google OAuth be configured with a specific "hd" (hosted domain) parameter?

查看:67
本文介绍了如何使用特定的"hd"配置Firebase + Google OAuth? (托管域)参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将Firebase与Google身份验证提供程序一起使用.

I'm using Firebase with the Google authentication provider.

在其他应用程序中使用Google OAuth时,我可以将身份验证配置为仅限于特定域.

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

Google OpenID Connect文档详细说明了用于此功能的"hd"参数. https://developers.google.com/identity/protocols/OpenIDConnect#hd-param

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

如何为Firebase配置它?

How can this be configured for Firebase?

推荐答案

使用新的setCustomParameters函数,您可以添加hd参数

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);

这是API文档 https://firebase. google.com/docs/reference/js/firebase.auth.GoogleAuthProvider#setCustomParameters

至少需要Firebase 3.5.0版-2016年10月14日. https://firebase.google.com/support/release-notes/js

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

这篇关于如何使用特定的"hd"配置Firebase + Google OAuth? (托管域)参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆