【发布时间】:2020-11-12 10:40:44
【问题描述】:
我正在使用 Firebase 身份验证进行登录和注册。我正在尝试集成 google 登录。现在我已经获得了一个 google Oauth ID,我需要将其转换为 Firebase ID 令牌,以便我可以使用授权标头登录。
const FirebaseIdToken = `Bearer ${token}`;
localStorage.setItem("FirebaseIdToken", FirebaseIdToken);
API.defaults.headers.common["Authorization"] = FirebaseIdToken;
我正在关注此链接:https://firebase.google.com/docs/reference/rest/auth/#section-sign-in-with-oauth-credential 以获取发帖请求,但我在执行此操作时遇到了问题。
const data = {
postBody: token, //Google Oauth token
};
API.post(
`https://identitytoolkit.googleapis.com/v1/accounts:signInWithIdp?key=[API-KEY]`,
{ data }
).then((res) => {
console.log(res);
console.log(res.data);
});
我刚刚收到一个 Post 400 错误。正文还要求一个 requestUri,我不确定那是什么。
【问题讨论】:
标签: reactjs firebase rest express firebase-authentication