如何从Angular 2的Firebase获取有效的访问令牌
问题描述:
我正在使用库angularfire2
进行身份验证。如何从Angular 2的Firebase获取有效的访问令牌
我需要使用令牌进行身份验证。如何生成令牌的使用:
import { AngularFireAuth } from 'angularfire2/auth';
[...]
this.angukarFireAuth.auth.signInWithCustomToken(TOKEN);
如果我通过一定的价值,我收到错误:The custom token format is incorrect. Please check the documentation.
答
生成自定义标记,您可以将火力地堡管理员SDK。 Admin Node.js SDK提供了一个createCustomToken(uid, customClaims)
方法。然后,您可以将生成的令牌发送到客户端signInWithCustomToken
。在此处了解更多信息:https://firebase.google.com/docs/auth/admin/create-custom-tokens