Sets an initial password for the currently authenticated user. This is for accounts that signed up through OAuth (or an external identity) and have no password yet — for example, so they can later sign in with email and password, or unlink their last OAuth identity without being locked out. Requires the user’s own access token in the Authorization header; a service key is refused (403 auth/user-token-required).
This endpoint is only for users who do not already have a password. If the
user already has one, use Change Password
instead, which verifies the current password before changing it.
Headers
string
required
Bearer {accessToken} — a valid access token for the authenticated user. A service key is refused.
Body Parameters
string
required
The password to set for the account.
Response
204 No Content on success, with no body.
Error Responses
User Not Found — 404
{ "error": "User not found.", "code": "auth/user-not-found"}
Already Password Authenticated — 400
{ "error": "User already has a password. Use change-password instead.", "code": "auth/already-password-authenticated"}
Returned when the user already has a password. Use
Change Password instead.
Session Ended — 401
{ "error": "This session has ended. Sign in again.", "code": "auth/session-ended" }
The access token is still valid, but its session no longer exists (signed out, password reset, or the account was claimed by a provider sign-in after its email went unverified). Adding a password needs a live session, so sign in again.
User Token Required — 403
A service key called this endpoint, with or without actingUserId. It needs the signed-in user’s own access token.
{ "error": "This endpoint needs the user's own access token; a service key can't use it.", "code": "auth/user-token-required"}
Acting User Not Allowed — 400
A user token, or a request with no credentials, sent actingUserId, even naming its own user. A user token always acts as its own user. (A service key gets the 403 above instead.)
{ "error": "actingUserId is only accepted with a service key. A user's own token always acts as that user.", "code": "auth/acting-user-not-allowed"}
Unsupported Parameter — 400
The request sent userId, in the body or the query. These endpoints always act as the signed-in user, so there is no user to name.
{ "error": "`userId` isn't accepted here: these endpoints always act as the signed-in user.", "code": "auth/unsupported-param", "param": "userId"}