Integrate
Email and password
Signing users up and in with an email and a password, including the two-factor step.
Sign-up
Creates the user in your app and signs them in:
ts
const tokens = await identise<{ accessToken: string; refreshToken: string }>("/v1/oauth/register", { email, password });Answers 409 User.EmailInUse if the email already has an account in your app.
Passwords must be 8 to 256 characters: anything else answers
400 Password.Invalid, with the reason in errors.password (see validation errors). Identise checks length only, so check strength in your own sign-up form too.Sign-in
POST /v1/oauth/login with { appId, email, password } answers 200 with tokens, or 202 when the user has two-factor authentication on:
ts
const res = await fetch(`${IDENTISE}/v1/oauth/login`, {
method: "POST",
headers: { "Content-Type": "application/json", "X-Api-Key": API_KEY, "X-Client-Ip": clientIp },
body: JSON.stringify({ appId: APP_ID, email, password }),
});
if (res.status === 202) {
const { mfaToken } = await res.json(); // ask for the 6-digit code, then POST /v1/oauth/verify-mfa
} else if (res.ok) {
const { accessToken, refreshToken } = await res.json();
}| Answer | Means |
|---|---|
200 | Signed in: { accessToken, refreshToken }. |
202 | { requiresMfa: true, mfaToken }: finish with the two-factor step. |
401 Security.Unauthorized | A wrong email or password. It doesn't say which. |
403 User.Suspended | The user is suspended. |
Then keep them signed in with the refresh token.