Your account

Refresh an access token

Exchange a refresh token for a new access token and a new refresh token with POST /v1/auth/refresh-token.

MethodPath
POST/v1/auth/refresh-token

Authentication · Account routes

Exchanges a refresh token for a new access token and a new refresh token. Call it before the access token expires to keep a session alive.

This is an account-level route. It has no /v1/auth/tenant/ variant. Use the refreshToken that a tenant sign-in or registration returned.

Auth: None. The refresh token in the body is the credential. Scope: The session the refresh token belongs to.

Request

Body

NameTypeRequiredDescription
refresh_tokenstringYesThe refresh token of the session. At least 1 character. The request field stays in snake case.

Behaviour

  • The answer uses accessToken, refreshToken and expiresIn. It also includes the deprecated access_token, refresh_token and expires_in fields for one release; read only the camelCase fields. refreshToken may be null.
  • Store the new refreshToken and use it for the next refresh.
  • The access token is valid for one hour. expiresIn is in seconds.
  • A refused refresh token (spent, expired, revoked or not a refresh token) gives 401; sign in again. A token-store failure with no OAuth error stays 400.
  • A session of a patient whose project turned PATIENT_LOGIN_ENABLED off, or of a practitioner whose project turned PRACTITIONER_LOGIN_ENABLED off, gives 403 with Login is not enabled for this project. That ends the session: the refresh token is used up, and signing in again is refused while login is off.
  • A practitioner who is a project admin is not refused, so a signed-in admin can still turn login back on. They cannot sign in again while it is off.
  • The route is rate limited to 600 requests per minute for each caller. Over the limit the answer is 429, which can sign a user out, so refresh once per token lifetime and not in a loop.

Example

curl -X POST 'https://api.sandbox.ovok.com/v1/auth/refresh-token' \
  -H 'Content-Type: application/json' \
  -d '{
    "refresh_token": "<refresh token from sign-in>"
  }'

Successful response

201 — A new token pair.

{
  "accessToken": "<new access token>",
  "refreshToken": "<new refresh token>",
  "expiresIn": 3600,
  "access_token": "<deprecated duplicate>",
  "refresh_token": "<deprecated duplicate>",
  "expires_in": 3600
}
FieldTypeDescription
accessTokenstringBearer access token. Valid for one hour.
refreshTokenstring | nullThe refresh token to use next, or null.
expiresInintegerLifetime of the access token, in seconds.
access_tokenstringDeprecated duplicate; read accessToken. Removed one release after this compatibility period.
refresh_tokenstring | nullDeprecated duplicate; read refreshToken. Removed one release after this compatibility period.
expires_inintegerDeprecated duplicate; read expiresIn. Removed one release after this compatibility period.

Errors

StatusMeaning
400The token store could not process the request and returned no OAuth error, or refresh_token is missing or empty.
401The refresh token is spent, expired, revoked or not a refresh token. The response includes WWW-Authenticate: Bearer; sign in again.
403Login is switched off for the project of a patient or of a non-admin practitioner. The session ends.
429More than 600 requests in a minute from the same caller.

Last updated on

On this page