为什么我找不到一些使用 firebase api 的用户?
Why can I not find some users using firebase api?
我正在尝试使用管理员 API.
从 firebase 函数中检索用户
执行这项工作的代码是:
async function getUserByUid(uid: string) {
const user = await admin.auth().getUser(uid);
return mapUser(user);
}
在我的日志中,我可以看到 2 个获取用户的请求,一个有效,另一个无效。
工作
5:33:19.911 pm api Received request to get students for uid
<Oge21mpIxaVQhVQblg61bhrZkZp1>
5:33:22.509 pm api Function execution took 2604 ms, finished with
status code: 304
不工作
11:47:08.849 pm api Received request to get students for uid
<fhxxrstB02QhbXcYHDIKKsmQubV2>
11:47:10.983 pm api Error occurred {
Error: There is no user record corresponding to the provided
identifier.
at FirebaseAuthError.FirebaseError [as constructor] (/workspace/node_modules/firebase-admin/lib/utils/error.js:42:28)
at FirebaseAuthError.PrefixedFirebaseError [as constructor] (/workspace/node_modules/firebase-admin/lib/utils/error.js:88:28)
at new FirebaseAuthError (/workspace/node_modules/firebase-admin/lib/utils/error.js:147:16)
at /workspace/node_modules/firebase-admin/lib/auth/auth-api-request.js:518:15
at /workspace/node_modules/firebase-admin/lib/auth/auth-api-request.js:1476:13
at process._tickCallback (internal/process/next_tick.js:68:7) errorInfo: { code: 'auth/user-not-found',
message:
'There is no user record corresponding to the provided identifier.' }, codePrefix: 'auth' }
在这两种情况下,我都可以在 firbase 管理的 authentication/users 部分找到用户。两者的 uid 绝对正确。两个用户都未被禁用。
我在 australia-southeast1 地区的职能 运行。 export const api = functions.region("australia-southeast1")
我想弄清楚为什么对某些用户有效的相同代码对其他用户不起作用。
事实证明,在我阅读了有问题的用户之后,我试图从他们的一名学生那里检索不存在的数据。谜底揭晓。
我正在尝试使用管理员 API.
从 firebase 函数中检索用户执行这项工作的代码是:
async function getUserByUid(uid: string) {
const user = await admin.auth().getUser(uid);
return mapUser(user);
}
在我的日志中,我可以看到 2 个获取用户的请求,一个有效,另一个无效。
工作
5:33:19.911 pm api Received request to get students for uid <Oge21mpIxaVQhVQblg61bhrZkZp1>
5:33:22.509 pm api Function execution took 2604 ms, finished with status code: 304
不工作
11:47:08.849 pm api Received request to get students for uid <fhxxrstB02QhbXcYHDIKKsmQubV2>
11:47:10.983 pm api Error occurred { Error: There is no user record corresponding to the provided identifier. at FirebaseAuthError.FirebaseError [as constructor] (/workspace/node_modules/firebase-admin/lib/utils/error.js:42:28) at FirebaseAuthError.PrefixedFirebaseError [as constructor] (/workspace/node_modules/firebase-admin/lib/utils/error.js:88:28) at new FirebaseAuthError (/workspace/node_modules/firebase-admin/lib/utils/error.js:147:16) at /workspace/node_modules/firebase-admin/lib/auth/auth-api-request.js:518:15 at /workspace/node_modules/firebase-admin/lib/auth/auth-api-request.js:1476:13 at process._tickCallback (internal/process/next_tick.js:68:7) errorInfo: { code: 'auth/user-not-found', message: 'There is no user record corresponding to the provided identifier.' }, codePrefix: 'auth' }
在这两种情况下,我都可以在 firbase 管理的 authentication/users 部分找到用户。两者的 uid 绝对正确。两个用户都未被禁用。
我在 australia-southeast1 地区的职能 运行。 export const api = functions.region("australia-southeast1")
我想弄清楚为什么对某些用户有效的相同代码对其他用户不起作用。
事实证明,在我阅读了有问题的用户之后,我试图从他们的一名学生那里检索不存在的数据。谜底揭晓。