firebase - 在 Firebase Auth REST API 中的“更改密码”POST 请求后,我无法获得 refreshToken
问题描述
我正在尝试使用 Firebase Auth REST API 文档中的“更改密码”部分更改用户密码。我提出请求。我收到了回复,但我的回复中没有 refreshToken。
这是我的要求:
export const changePassword = async (token,password) => {
const response = await fetch(
'https://identitytoolkit.googleapis.com/v1/accounts:update?key=[API_KEY]',
{
method: 'POST',
headers: {
'Content-type': 'application/json',
},
body: JSON.stringify({
idToken: token,
password: password.newPassword,
returnSecureToken: true,
}),
},
);
if (!response.ok) {
const errorResData = await response.json();
const errorId = errorResData.error.message;
let message = 'Something went wrong!';
if (errorId === 'EMAIL_NOT_FOUND') {
message = 'This e-mail can not be found.';
} else if (errorId === 'INVALID_PASSWORD') {
message = 'This password is invalid!';
}
throw new Error(message);
}
const resData = await response.json();
console.log(resData);
这是我的console.log(resData);
下面:
email: "email@gmail.com"
emailVerified: false
kind: "identitytoolkit#SetAccountInfoResponse"
localId: "localId..."
passwordHash: "UkVEQUNURUQ="
providerUserInfo: [{…}]
这就是我得到的。我不知道下一步该做什么,这是一个紧急项目。我没有任何刷新令牌。我怎样才能得到它,如果我得到它,我下一步该怎么做?
谢谢
解决方案
推荐阅读
- javascript - 如何让全局变量留在角度构造函数和承诺中,调用需要来自 diff 组件的数据的函数
- javascript - 自定义设置方法不起作用(javascript)
- android - Android 运行时错误:芯片膨胀期间发生的 ID 0x00000001 无效
- apache-spark-sql - 在 Spark SQL 中使用字符串变量作为日期过滤观察结果
- android - 我必须有一个结算帐户才能使用 Google Maps Api 密钥吗?
- python - 有没有办法在 Django 模型中拥有一个列表类型的对象?
- python - 随机化项目和循环列表(Python)
- java - 在另一个函数的参数中实现的函数的android java语法是什么
- javascript - 如何在多个复选框中执行相同的功能?
- asp.net - 在 .NET Core WebAPI 3.1 中使用受限字符串字段值