如何将 Firebase 自定义身份验证与 openID 提供商结合使用?
How can I use Firebase custom auth with an openID provider?
我目前有一个游戏网络项目,我希望用户能够登录以共享内容,目前已使用 google 的 firebase 身份验证完成(并且工作正常)。
但我希望人们能够通过 Steam 进行身份验证(使用 Oauth2)
firebase reference/API (https://firebase.google.com/docs/auth/web/custom-auth) 没有帮助,因为我找不到我需要实施的确切(工作)示例,而且我没有太多经验尚未使用 Oauth2 或 Firebase。
来自 http://steamcommunity.com/dev I got my API key and that I should use "http://steamcommunity.com/openid" 作为提供商。
我试过这样使用它:
var provider = new firebase.auth.OAuthProvider("steamcommunity.com/openid");
firebase.auth().signInWithPopup(provider).catch(function(error)
{
console.log(error.message);
});
这是适用于所有默认提供商(Google、Twitter、Facebook 等)的基本功能
但是我在控制台中得到一个 "provider ID not supported",我显然忘记了某处的东西,但我真的不知道它到底是什么(我知道我应该输入 API来自 Steam 某处的秘密)而且我不确定从哪里开始寻找(例如,我是否需要更改我的 firebase 设置中的任何内容,..)
如果有人能帮助我解决我的问题或指出一个我可以通过的工作示例,那将非常有帮助,因为我的谷歌搜索只让我找到了官方的 firebase 参考资料和 API 和到目前为止,这些并没有真正帮助我。
firebase.auth.OAuthProvider
目前仅支持现有提供程序,尚未扩展以支持其他提供程序。
您将需要使用自定义身份验证。我刚刚用谷歌搜索并找到了这个用于 Steam 身份验证的库:https://www.npmjs.com/package/steam-login. You can use that to sign in with Steam and then get the Steam user ID, mint a custom token with it using Firebase Admin SDK: https://firebase.google.com/docs/auth/admin/create-custom-tokens using that Steam UID and then send the custom token to the client to complete sign in with signInWithCustomToken
: https://firebase.google.com/docs/auth/web/custom-auth
您可以使用 GCP 提供的身份平台来做到这一点。您可以在以下 link 中找到文档。您需要有一个启用了计费的 Firebase 项目才能这样做。
https://cloud.google.com/identity-platform/docs/web/oidc
首先,您必须在 GCP 控制台中配置新的 OpenID Connect 提供程序。然后您可以简单地使用 Firebase OAuthProvider,就像您通常使用其他 Firebase 提供的 OAuth 服务一样。
我不会在这里解释每个步骤,因为文档包含您需要知道的一切。
我目前有一个游戏网络项目,我希望用户能够登录以共享内容,目前已使用 google 的 firebase 身份验证完成(并且工作正常)。
但我希望人们能够通过 Steam 进行身份验证(使用 Oauth2)
firebase reference/API (https://firebase.google.com/docs/auth/web/custom-auth) 没有帮助,因为我找不到我需要实施的确切(工作)示例,而且我没有太多经验尚未使用 Oauth2 或 Firebase。
来自 http://steamcommunity.com/dev I got my API key and that I should use "http://steamcommunity.com/openid" 作为提供商。
我试过这样使用它:
var provider = new firebase.auth.OAuthProvider("steamcommunity.com/openid");
firebase.auth().signInWithPopup(provider).catch(function(error)
{
console.log(error.message);
});
这是适用于所有默认提供商(Google、Twitter、Facebook 等)的基本功能
但是我在控制台中得到一个 "provider ID not supported",我显然忘记了某处的东西,但我真的不知道它到底是什么(我知道我应该输入 API来自 Steam 某处的秘密)而且我不确定从哪里开始寻找(例如,我是否需要更改我的 firebase 设置中的任何内容,..)
如果有人能帮助我解决我的问题或指出一个我可以通过的工作示例,那将非常有帮助,因为我的谷歌搜索只让我找到了官方的 firebase 参考资料和 API 和到目前为止,这些并没有真正帮助我。
firebase.auth.OAuthProvider
目前仅支持现有提供程序,尚未扩展以支持其他提供程序。
您将需要使用自定义身份验证。我刚刚用谷歌搜索并找到了这个用于 Steam 身份验证的库:https://www.npmjs.com/package/steam-login. You can use that to sign in with Steam and then get the Steam user ID, mint a custom token with it using Firebase Admin SDK: https://firebase.google.com/docs/auth/admin/create-custom-tokens using that Steam UID and then send the custom token to the client to complete sign in with signInWithCustomToken
: https://firebase.google.com/docs/auth/web/custom-auth
您可以使用 GCP 提供的身份平台来做到这一点。您可以在以下 link 中找到文档。您需要有一个启用了计费的 Firebase 项目才能这样做。
https://cloud.google.com/identity-platform/docs/web/oidc
首先,您必须在 GCP 控制台中配置新的 OpenID Connect 提供程序。然后您可以简单地使用 Firebase OAuthProvider,就像您通常使用其他 Firebase 提供的 OAuth 服务一样。
我不会在这里解释每个步骤,因为文档包含您需要知道的一切。