Skip to main content

Obtaining Access Tokens

DVS uses the OAuth2 client credentials grant for service-to-service authentication. The OSIGU Auth Server uses HTTP Basic auth for client identification and query string for the grant type — this page shows you the exact request shape and copy-paste implementations in 5 languages.

Endpoints

EnvironmentToken URL
Sandboxhttps://sandbox.osigu.com/v1/oauth/token
Productionhttps://api.osigu.com/v1/oauth/token

Credentials are environment-scoped — sandbox client_id does not work against the production token URL.

Request shape

grant_typestringrequired

Sent as a query string parameter (not in the body). Always client_credentials.

Authorizationheaderrequired

HTTP Basic auth: Basic <base64(client_id:client_secret)>. Use the credentials OSIGU issued for the target environment.

Method: POST Body: empty Content-Type: not required (no body)

Response

{
"access_token": "7dd4f350-676e-4257-9d7b-f3c5ac4dfi14",
"token_type": "bearer",
"expires_in": 86399,
"scope": "read write",
"extensions": {
"provider_slug": "br-gamma"
}
}
FieldDescription
access_tokenOpaque token (not a JWT). Send as Authorization: Bearer <token> on subsequent DVS API calls.
token_typeAlways bearer.
expires_inSeconds until expiration. Default is 86399 (~24 hours).
scopeCoarse OAuth2 scope granted to the token (e.g., read write). DVS's finer per-endpoint authorities are enforced server-side from your client_id configuration.
extensionsFree-form metadata map. Includes your provider_slug (use it to log which tenant the token belongs to). May include other tenant-scoped fields OSIGU adds in the future.

Code samples

curl --location --request POST \
"https://sandbox.osigu.com/v1/oauth/token?grant_type=client_credentials" \
--header "Authorization: Basic $(echo -n "$DVS_CLIENT_ID:$DVS_CLIENT_SECRET" | base64)"

Best practices

Cache tokens

Tokens are valid for ~24 hours by default. Cache them in memory (or shared cache like Redis for multi-instance services) and refresh ~60 seconds before expiry. Calling the OAuth endpoint on every API request will rate-limit you and add unnecessary latency.

Store secrets in a vault, not env files

Use AWS Secrets Manager, HashiCorp Vault, Doppler, or equivalent. Rotate client_secret annually (or after any suspected exposure) by contacting OSIGU.

Handle 401 by refreshing

If a request returns 401, the token may have expired or been revoked. Drop the cached token, request a new one, and retry the original request once. Don't retry infinitely.

Don't log tokens

Strip Authorization headers from your application logs. A leaked token is valid for up to 24 hours.

Use extensions.provider_slug for observability

Log the provider_slug from the token response alongside your request IDs. It makes correlating issues with OSIGU support much faster.

Errors

StatusBodyCause
400error: "invalid_request"Missing grant_type query string.
401error: "invalid_client"Wrong client_id or client_secret, or wrong environment (sandbox creds against production URL).
405Method Not AllowedYou used GET instead of POST.
429rate limitedToo many token requests. Cache and slow down.
5xxserver errorAuth Server outage. Retry with exponential backoff (max 3).