我现在正在处理 firebase auth,我正在关注这个 Firebase 文档。
访问https://firebase.google.com/docs/auth/admin/manage-cookies#sign_in
// When the user signs in with email and password.
firebase.auth().signInWithEmailAndPassword('user@example.com', 'password').then(user => {
// Get the user's ID token as it is needed to exchange for a session cookie.
return user.getIdToken().then(idToken = > {
// Session login endpoint is queried and the session cookie is set.
// CSRF protection should be taken into account.
// ...
const csrfToken = getCookie('csrfToken')
return postIdTokenToSessionLogin('/sessionLogin', idToken, csrfToken);
});
})
Run Code Online (Sandbox Code Playgroud)
我希望我可以通过使用该功能获得令牌。但它不起作用,因为代码中的用户没有 getIdToken() 函数。