Skip to main content
The Authorization Code flow uses a client_secret to authenticate when exchanging the authorization code for tokens. Use this flow when your application runs on a server and can securely store credentials — for example, Node.js, Python, or PHP backends.

Prerequisites

Before you implement this flow, ensure you have:
  • OAuth2 client credentialsRegister your app in Client Center / Manage Account to get client_id and client_secret
  • Redirect URI — Must be pre-registered in Client Center / Manage Account and must exactly match (protocol, host, path, trailing slashes)
  • Server-side runtime — Node.js 18+, Python 3.8+, or equivalent for your language
  • Session or secure storage — To persist state between redirect and callback, and to store tokens after exchange
The client_secret is shown only once when you create the client. Copy it immediately and store it in environment variables or a secrets manager. If lost, regenerate it in Client Center / Manage Account.

Step 1: Build the authorization URL and redirect

Redirect the user to the Aries authorization endpoint. They will see a login and consent screen where they can approve or deny the requested permissions. Endpoint: https://app.aries.com/oauth2/authorize Required query parameters:
Always generate a new, cryptographically random state for each authorization request and verify it when the user returns. This prevents CSRF attacks.

Step 2: Handle the callback

After the user approves, Aries redirects to your redirect_uri with an authorization code and the state you provided. If the user denies access, you receive error parameters instead. Success callback:
Error callback (user denied or error):

Step 3: Exchange the code for tokens

Send the authorization code to the token endpoint to receive an access token and refresh token. The code is single-use — exchange it immediately after receiving it. Endpoint: POST https://api.aries.com/v1/oauth2/token Request body:
Response:
Store the access_token, refresh_token, and expires_in (use it to compute expiry time). Replace your stored refresh_token if a new one is returned.

Step 4: Make authenticated API requests

Include the access token in the Authorization header for every API request.

Step 5: Refresh the access token

Access tokens expire after expires_in seconds (typically 1 hour). Use the refresh token to obtain a new access token without requiring the user to log in again. Refresh proactively before expiry. Endpoint: POST https://api.aries.com/v1/oauth2/token Request body:
The response format is the same as the initial token exchange. If a new refresh_token is returned, persist it — it replaces the previous one.

Complete example (Node.js)

Here is a minimal Express.js server demonstrating the full flow:
Node.js

Next steps

OAuth2 Overview

Scopes, security, rate limits, and troubleshooting.

PKCE Flow

Implement OAuth2 for SPAs and mobile apps.

Token API Reference

Interactive token endpoint reference.

Quick Start

Get started in minutes.