Christopher Tse, Oliver Caine, Robert Wave, Girish Padmanabha
Changed on:
28 Jan 2026
Overview
APIs use authorization to ensure that client requests access data securely. This involves authenticating the sender of a request and verifying that they have permission to access or manipulate the relevant data. The authentication request returns a bearer token that can be used in subsequent API calls to confirm authentication.This guide covers the complete OAuth 2.0 authentication flow, including credential management, token lifecycle, and security best practices for production environments.
Key points
Token lifecycle management - Understand how to handle access tokens, refresh tokens, and expiration scenarios
Security best practices - Form data submission is recommended over query strings for credential protection
Integration options - Choose between standard client and FLUENT_INTEGRATION client based on your needs
APIs use authorization to ensure that client requests access data securely. This involves authenticating the sender of a request and verifying that they have permission to access or manipulate the relevant data.
Bearer Token
The authentication endpoint returns a bearer token that can be used in the header of subsequent API calls to confirm authentication and maintain secure access.
Authentication Flow
Token Lifecycle Diagram
OAuth 2.0 Architecture
API Specifications
Technical details and endpoint configuration
Property
Value
URL
`<root_url>/oauth/token?<API Credentials>`
Methods
`POST`
Scheme
`https`
Content-Type
`See parameter submission methods below`
Headers
`fluent.account: <ACCOUNT_ID> `
Content-Type Usage
Recommended (Form Data):`Content-Type: application/x-www-form-urlencoded`Alternative (Query String):`Content-Type: application/json` or omit headerSee the Parameter Submission Methods section below for detailed security considerations.
Operations
Available authentication endpoints and methods
[POST] /oauth/token - Authentication Endpoint
This endpoint uses the provided username, password, client ID & client secret to generate an authentication token.
API CredentialsThe customer/partner will receive an email from Fluent Commerce that will contain the following information:
Credentials Information
If you did not receive the credential details, please contact one of the Fluent Friendly staff.
Name
Multiple?
Description
API Key
❌ No
This API key is to be used in the Store Locator and other Javascript widgets
API Client ID and secret
❌ No
The API Client grants the retailer access to the content via the Fluent REST API. Each retailer will have one API Client
Parameter Submission Methods
Recommended approaches for sending authentication parameters
Recommended: Form Data Parameters
We support and recommend sending authentication parameters via form data (application/x-www-form-urlencoded) instead of query strings for enhanced security.Why Form Data is Preferred
Security: Parameters are sent in the request body, not visible in URLs
Privacy: Credentials won't appear in server logs or browser history
Length Limits: No URL length restrictions for complex parameters
Best Practice: Follows OAuth 2.0 security recommendations
Integration Users - users for the FLUENT_INTEGRATION client id - have a short-lived token authentication flow. These users are set up with short-lived access tokens (30 minutes / 1800 seconds by default) and are issued a refresh token. This refresh token can be used with the login endpoint endpoint to renew authentication without sending a username and password. A shorter expiry time enhances security by ensuring that any tokens issued are not valid for longer than necessary, and the refresh token allows integrations to stay authenticated without continuously sending sensitive credentials to Fluent.Refresh tokens issued for FLUENT_INTEGRATION client types expire after 24 hours / 86400 seconds
The FLUENT_INTEGRATION client is designed specifically for integrations with the Fluent platform as it has the refresh token functionality enabled by default. Required parameters:
`client_id=FLUENT_INTEGRATION`
`scope=retailer`
Note: The `client_secret` is unique to the FLUENT_INTEGRATION client_id, and can be obtained by submitting a ticket through our support platform.
Refresh tokens are single-use. Trying to reuse them will result in an "Invalid refresh token" error.
Usage in Mystique: Refresh tokens are currently used in Mystique to ensure a user remains logged in when they have a browser session open. The access token is checked every 30s to validate how much time is remaining until expiry. If the access token is close to expiring, the refresh token is automatically used to retrieve a new access token.
Understanding Response Objects
When you receive a successful authentication response, each field serves a specific purpose:
`access_token`
Purpose: Your main authentication credential for API calls.Usage: Include this in the Authorization header of all subsequent API requests.`Authorization: Bearer cf02e220-86ea-408d-9b80-fb55f517725b`Security: Store securely, never expose in client-side code or URLs.
`token_type`
Purpose: Specifies the type of token (typically "bearer").Usage: Use this value in the Authorization header format.
`expires_in`
Purpose: Number of seconds until the access token expires.Usage: Calculate expiration time and implement token refresh logic before expiry.Example: If expires_in is 86386 seconds (≈ 24 hours), refresh the token 5-10 minutes before expiration.
`refresh_token`
Purpose: Used to obtain new access tokens without re-authentication.Usage: Store securely and use when access token is near expiration.
Important:
Refresh tokens are single-use and expire after being used.
`scope`
Purpose: Defines the level of access granted (e.g., "api", "retailer").Usage: Determines which API endpoints and operations you can access.
`Retailer_id, FirstName, LastName, Roles`
Purpose: User and account context information.Usage: Use for personalization, authorization checks, and audit logging.
Token Lifecycle Management
Proper token management is crucial for maintaining secure and uninterrupted API access.
1. Initial Authentication
Store both access_token and refresh_token securely. Calculate expiration time using expires_in value.
2. Token Usage
Use access_token in Authorization header for all API calls. Monitor token expiration time.
3. Proactive Refresh
Refresh token 5-10 minutes before expiration to avoid service interruption.
4. Handle Expiration
If you receive 401 Unauthorized, immediately attempt token refresh or re-authentication.
Best Practices
Secure Storage: Never store tokens in localStorage or sessionStorage in web apps
Token Rotation: Always use the new refresh_token returned with each refresh
Error Handling: Implement proper error handling for token refresh failures
Monitoring: Log token refresh events for debugging and monitoring
Cleanup: Clear tokens on logout or authentication errors
Using the Access Token
Once you have the access token, include it in the Authorization header of your API requests:`Authorization: Bearer your-access-token-here`Replace "your-access-token-here" with the actual access_token value from the authentication response.
Models
Data structures for requests and responses
Response Model
Key
Type
Required
Description
access_token
String
✅
The access token string as issued by the authorization server
token_type
String
✅
The type of token. This will typically be the string “bearer”
expires_in
Integer
❌
If the access token expires, this field will return a value in seconds until the token expires
scope
String
❌
The scope of the access token
refresh_token
String
❌
Refresh tokens can be used to fetch a new access token without needing username and password
Retailer_id
Integer
❌
This is a unique ID associated with the retailer
Roles
[String]
❌
An array of the Roles associated with the returned token
FirstName
String
❌
The first name of the user account that requested the token
LastName
String
❌
The last name of the user account that requested the token