/v1/auth/signinSign in with email/username and password
Every failed attempt answers `401 INVALID_CREDENTIALS`, whatever went wrong: unknown identifier, wrong password, an account with no password credential, an account locked out through a different identifier, an account an operator has blocked, and a wrong password against a suspended or deactivated account. The responses are deliberately identical in body and timing, so sign-in never reveals whether an account exists. An account with two-step sign-in on answers `200` with a challenge instead of tokens (`mfa_required: true`, `mfa_token`, `factors`): finish with `POST /v1/auth/mfa/verify`. Tell the two apart by `mfa_required`. The challenge is only ever returned for a correct password.
Request body
identifier*stringEmail or username
Example: "user@example.com"
password*stringUser password
Example: "MySecurePassword123"
session_durationobjectSession duration: "short" (24h), "long" (90d), or integer seconds (3600–7776000). Defaults to 30 days.
Example: "short"
Response · 200 Tokens, or (two-step sign-in on) a challenge to finish with `POST /v1/auth/mfa/verify`.
object
Example
Request
POST https://api.platform-auth.productcraft.co/v1/auth/signin
Content-Type: application/json
{
"identifier": "user@example.com",
"password": "MySecurePassword123",
"session_duration": "short"
}import { PlatformAuth } from "@productcraft/platform-auth";
// Reads PRODUCTCRAFT_API_KEY from the environment; administration
// calls take a person's session: { auth: { type: "bearer", token } }
const platform = new PlatformAuth();
const token = await platform.auth.signin({ identifier: "user@example.com", password: "MySecurePassword123" });platform.auth.signin(params, options?): PlatformAuth.Token
Response
{}