Skip to main content

Authentication

Most operations on the Vasco API require authentication. Authentication uses OAuth 2.0 with the client_credentials grant: your integration exchanges its own client credentials for a short-lived access token at the /oauth/token endpoint, then sends that token as a Bearer credential on every request to the authenticated GraphQL endpoint.

Prerequisites
  • Pick the environment you want to target — see API endpoints.
  • Request an OAuth2 client from Vasco — see Getting an OAuth2 client below. You cannot authenticate without one.
  • Have a user account. Users can register themselves through the public CreateUser mutation, or be created by an admin (see the User Management recipe). Your OAuth2 client acts as this user.

Getting an OAuth2 client​

The client_credentials flow requires a client_id and a client_secret that identify your integration. These are issued by Vasco: they are not self-service.

To obtain them, contact Vasco and provide:

  • The environment(s) you need access to (production, preproduction).
  • A short description of your integration and the operations it needs to perform.
  • The user account your client must act as.

Vasco will provision a confidential OAuth2 client allowed to use the client_credentials grant, and bind it to the user you designated — referred to as the service account user in the rest of this guide. Every token issued to your client acts as the service account user: what your integration can do is exactly what this user's roles and permissions allow.

Keep your secret safe

The client_secret grants access to the API as the service account user, without any second factor. Store it in a secret manager, never commit it to source control, and never expose it in a browser or mobile client. If it leaks, ask Vasco to rotate it.

Obtaining a token​

Send a POST request to /oauth/token with the client_credentials grant:

curl -X POST https://api.<client>.vasco.fund/oauth/token \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=client_credentials" \
-d "client_id=<YOUR_CLIENT_ID>" \
-d "client_secret=<YOUR_CLIENT_SECRET>" \
-d "scope=vasco:full"
ParameterDescription
grant_typeAlways client_credentials.
client_idYour client identifier, issued by Vasco.
client_secretYour client secret, issued by Vasco.
scopeAlways send vasco:full. A token requested without it carries no scope.

A successful response is a standard OAuth2 token payload:

{
"token_type": "Bearer",
"expires_in": 900,
"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJpXXXXXX.YYYYYY"
}
FieldDescription
access_tokenThe JWT to send on authenticated requests. Valid for expires_in seconds.
expires_inAccess token lifetime in seconds (15 minutes by default).
token_typeAlways Bearer.

Using the token​

Pass the access token as a Bearer credential on every request to the authenticated GraphQL endpoint:

POST /graphql/ HTTP/1.1
Host: api.<client>.vasco.fund
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJpXXXXXX.YYYYYY
Content-Type: application/json

{ "query": "query { GetCurrentUser { id email } }" }

GetCurrentUser returns the service account user.

Token lifetime​

The client_credentials grant issues no refresh token: your integration holds its secret and can request a new access token whenever it needs one.

Cache the access token and reuse it across requests until it expires, then request a new one with the same call. Do not request a new token for every API call.

Revoking a token​

To invalidate an access token before it expires - for example if it may have leaked - revoke it at /oauth/revoke (RFC 7009):

curl -X POST https://api.<client>.vasco.fund/oauth/revoke \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "token=<ACCESS_TOKEN>" \
-d "token_type_hint=access_token"

The endpoint returns 200 even for an unknown or malformed token - revocation is idempotent. The one exception is a missing or empty token parameter, which returns 400 with error: invalid_request.

Revoking a token does not affect your client: you can request a new token right away. If your client_secret may have leaked, ask Vasco to rotate it.

Error responses​

Errors follow the OAuth2 convention — a JSON body with an error code and an optional error_description:

{
"error": "invalid_client",
"error_description": "Client authentication failed"
}
HTTP statuserrorMeaning
400invalid_requestA required parameter is missing, or a missing or empty token parameter on /oauth/revoke.
400unsupported_grant_typeUnknown grant_type value.
400invalid_scopeThe requested scope does not exist.
401invalid_clientUnknown client_id, wrong client_secret, or a client that is not allowed to use the client_credentials grant.
401access_deniedThe credentials are valid, but the service account user is missing or deactivated. Contact Vasco.

When an authenticated GraphQL request is rejected because the access token is missing, malformed, expired, or revoked, request a new token from /oauth/token.

Forgotten password​

A user who has lost their password can trigger the standard reset flow without being authenticated:

  1. RequestPasswordReset — sends a reset email to the user.
  2. ResetPassword — consumes the token from the email and sets a new password.

Operations that do not require a token​

Sign-up and password-reset operations are exposed on the public GraphQL endpoint and can be called anonymously. Browse the Public API section of the API Reference for the full list.

Deprecated: password login (/auth/login)​

Deprecated

The legacy POST /auth/login endpoint — which exchanges a username and password directly for a JWT — is deprecated and will be removed in a future release. It does not support OAuth2 client credentials, refresh tokens, or token revocation. Migrate all integrations to the OAuth2 client_credentials flow above.

For reference, the deprecated flow sent credentials to /auth/login:

# Deprecated — do not use for new integrations.
curl -X POST https://api.<client>.vasco.fund/auth/login \
-H "Content-Type: application/json" \
-d '{
"username": "user@example.com",
"password": "<password>"
}'

and returned the JWT directly:

{ "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJpXXXXXX.YYYYYY" }

Migrating from /auth/login​

Legacy (/auth/login)OAuth2 (/oauth/token)
POST /auth/login, JSON bodyPOST /oauth/token, application/x-www-form-urlencoded body
username + password of a user accountgrant_type=client_credentials + client_id + client_secret + scope=vasco:full
No client credentialsRequires an OAuth2 client — request one from Vasco
Acts as the user whose credentials are sentActs as the service account user bound to your client
Response: { "token": "..." }Response: { "access_token": "...", "expires_in": 900, "token_type": "Bearer" }
Re-send credentials when the JWT expiresRequest a new token with the client credentials when it expires

When you request your OAuth2 client, designate the account your integration currently logs in with: it becomes your service account user, with the same permissions.

The way you attach the token to GraphQL requests is unchanged: pass it in the Authorization: Bearer header exactly as before. What changes is the token endpoint's response body — { "token": "..." } becomes { "access_token": "...", ... } — so read the token from access_token instead of token.