TotalBase
Reference

Authentication API

The /api/auth routes: sign-in, registration, passwords, verification, invitations and providers.

The routes under /api/auth sign users in to the Data API and handle their accounts. Unlike the rest of the API, they take their own bodies, not { "data": … }; answers use the usual envelope, and a route with nothing to return (sign-out, the password and email routes, accepting an invitation) answers 204 No Content. See Authentication for how sessions and tokens are used.

RouteAccessBodyDoes
POST /api/auth/loginpublic{ email, password }{ data: { token, user } }, a session token. Needs a role with API access
POST /api/auth/logoutsessionends the session
GET /api/auth/mesessionthe signed-in user
POST /api/auth/registerpublic{ email, password, name? }creates an account, when self-registration is on
POST /api/auth/password/forgotpublic{ email }emails a reset link; always answers 204
POST /api/auth/password/resetpublic{ token, password }sets a new password with a reset token
POST /api/auth/password/changesession{ currentPassword, newPassword }changes the signed-in user's password
POST /api/auth/email/verifypublic{ token }marks the email verified
POST /api/auth/email/resendpublic or session{ email } without a sessionsends a new verification link; without a session always answers 204
POST /api/auth/invitations/acceptpublic{ token, password }accepts an invitation and sets the password
GET /api/auth/oauth/{provider}public?redirect_to=starts sign-in with a provider
GET /api/auth/oauth/{provider}/callbackthe provider?code&statefinishes it, and redirects to redirect_to with the token

"Session" routes take a session token, not an API token: Authorization: Bearer <token>.

Answers worth knowing

AnswerWhen
401 AUTHENTICATION_REQUIRED, Invalid email or passworda wrong password, a locked account, or an account without API access: the same answer, so nothing is revealed
403 EMAIL_NOT_VERIFIEDa correct password on an unverified account, while verification is required
400 INVALID_CURRENT_PASSWORDa wrong current password on change
403 PERMISSION_DENIEDregistration while it's off; a password change on an account with no password yet
401 SESSION_EXPIREDan expired or revoked session

forgot and resend always succeed, so they can't be used to find out which emails have accounts.

Your own pages

Invitation, reset and verification emails link to TotalBase's pages by default. To handle these steps in your own application, point the links at it in Settings › Access › Authentication (Email links); your page receives the token and calls the matching route above.

Next steps