How Authentication Works
When a player completes the OAuth flow, the API sets two HTTP cookies on their browser or client:
Every protected endpoint reads the
access_token cookie on each request. If the token is within 5 minutes of expiry — or has been marked inactive — the middleware automatically exchanges it for a fresh pair using the refresh_token cookie. The renewed cookies are written to the response transparently, so the player’s session continues without any action required on your part.
Both cookies are scoped to the
cacolombia.co domain. If you are running a companion application on a subdomain, ensure your client is configured to send cross-subdomain cookies or proxy requests through the same origin.Starting the OAuth Flow
Initiate authentication by callingPOST /v1/oauth/:provider. This endpoint returns a provider authorization URL that you redirect your user to.
Supported providers
Endpoint
redirectUrl must be a whitelisted URL. Contact the CA Colombia team to add your domain to the allowlist.
Response
targetUrl. Store the state value so you can verify it matches when the callback arrives.
Example
Handling the OAuth Callback
After the player authorizes with the provider, the API handles the callback at:state and code, retrieves the player’s profile from the provider, creates or retrieves their platform account, and then:
- Sets the
access_tokenandrefresh_tokencookies on the response. - Redirects the player to your original
redirectUrlwith?state=<state>appended.
redirectUrl, their session cookies are already set and ready to use.
Callback redirect example
state value to match against what you stored in Step 1 to confirm the flow completed for the right session.
Using Your Session
Once cookies are set, all subsequent API requests are authenticated automatically — noAuthorization header is required. Simply include cookies in your requests.
Token Refresh
Token renewal is fully automatic and transparent. You do not need to implement any refresh logic. When the auth middleware processes a request and detects the access token is expiring within 5 minutes (or has already been marked inactive), it:- Reads the
refresh_tokencookie from the request. - Issues a new access token and refresh token pair.
- Writes the updated cookies to the response.
401 FAILED_TOKEN_RENEWAL and the player must re-authenticate by starting the OAuth flow again.
Error Codes
When authentication fails, the API returns a401 or 403 response with a JSON body containing a code field. Use this code to determine what went wrong and how to recover.
Error response shape
