OAuth2 implementation for SPAs and mobile apps using PKCE. Secures the authorization code flow without storing client_secret.
PKCE (Proof Key for Code Exchange) secures the OAuth2 flow for applications that cannot store a client_secret — such as single-page apps (React, Vue, Angular), native mobile apps, and client-side JavaScript. Instead of a client secret, you use a one-time code_verifier and its code_challenge to prove you initiated the authorization request.
OAuth2 client — Register your app in Client Center to get client_id (no client_secret required for PKCE)
Redirect URI — Must be pre-registered in Client Center; use the exact URL where your app handles the callback (e.g., https://yourapp.com/oauth/callback)
Runtime support — Browser with crypto.subtle or Node.js 18+ / Python 3.8+ for generating code_verifier and code_challenge
Storage for code_verifier — Store the code_verifier between the redirect and callback (e.g., sessionStorage in browser, secure storage in mobile apps)
PKCE is recommended for all public clients (SPAs, mobile apps). Even if your backend eventually handles the token exchange, starting with PKCE improves security.
Step 1: Generate code_verifier, code_challenge, and redirect
Generate a cryptographically random code_verifier, derive the code_challenge, and redirect the user to Aries. Store the code_verifier so you can send it when exchanging the code.Endpoint:https://app.aries.com/oauth2/authorizeQuery parameters (including PKCE):
After the user approves, Aries redirects to your redirect_uri with the authorization code and state. Retrieve the stored code_verifier and exchange the code for tokens. Do not use the code twice — exchange it once and immediately.
Step 3: Exchange the code for tokens (with code_verifier)
Send the authorization code and code_verifier to the token endpoint. Do not include client_secret — PKCE uses code_verifier instead.Endpoint:POST https://api.aries.com/v1/oauth2/tokenRequest body (PKCE):
Field
Required
Description
client_id
Yes
Your OAuth2 client ID
grant_type
Yes
code
code
Yes
The authorization code from the callback
redirect_uri
Yes
Must match the redirect URI used in Step 1
code_verifier
Yes
The original random value (not the hash) you sent as code_challenge
# Replace AUTHORIZATION_CODE and CODE_VERIFIER with values from your flowcurl -X POST 'https://api.aries.com/v1/oauth2/token' \ -H 'Content-Type: application/json' \ -d '{ "client_id": "YOUR_CLIENT_ID", "grant_type": "code", "code": "AUTHORIZATION_CODE", "redirect_uri": "YOUR_REDIRECT_URI", "code_verifier": "YOUR_CODE_VERIFIER" }'
Access tokens expire after expires_in seconds (typically 1 hour). Use the refresh token to get a new access token. For public clients (SPAs, mobile apps without a backend), refresh typically requires client_secret. If your PKCE app has no backend, consider using a Backend-for-Frontend (BFF) to perform refresh, or prompt the user to re-authenticate when the access token expires.Endpoint:POST https://api.aries.com/v1/oauth2/tokenIf you have a backend (e.g., BFF or server-side PKCE), use the same refresh format as the Authorization Code flow: