Overview
The amberSearch Public API uses OAuth 2.0 Authorization Code Grant to authenticate third-party applications. This flow allows users to authorize external applications to access amberSearch on their behalf without sharing their credentials.This is a beta version of our OAuth 2.0 implementation. Features may evolve as we continue to improve the API.
Base URL
All OAuth endpoints are available under:OAuth 2.0 Flow
The OAuth 2.0 Authorization Code Grant flow consists of the following steps:1
Client Redirects User to Authorization Endpoint
Your application redirects the user to
/api/oauth/authorize with your client credentials and desired scopes.2
User Authentication
The user authenticates with amberSearch (if not already logged in) and authorizes your application.
3
Authorization Code Issued
amberSearch redirects back to your application’s redirect URI with an authorization code.
4
Exchange Code for Access Token
Your application exchanges the authorization code for an access token by calling
/api/oauth/token.5
Access API with Token
Use the access token to make authenticated requests to amberSearch API endpoints.
Getting Started
To use OAuth 2.0 with the amberSearch API, you need OAuth client credentials (client_id and client_secret).
Once you receive your credentials:
- Store your
client_secretsecurely (e.g., environment variables, secret management services) - Never expose it in client-side code or public repositories
- Keep your credentials confidential and do not share them
Authorization Endpoint
Step 1: Redirect User to Authorization
Direct users to the authorization endpoint to begin the OAuth flow:| Parameter | Type | Required | Description |
|---|---|---|---|
response_type | string | Yes | Must be code |
client_id | string | Yes | Your OAuth client ID |
redirect_uri | string | Yes | Must match one of the registered redirect URIs |
scope | string | No | Space-separated list of requested scopes |
state | string | Recommended | Opaque value for CSRF protection |
Step 2: User Authentication
If the user is not logged into amberSearch, they will be redirected to the login page. After successful authentication, they are redirected back to continue the OAuth flow.Step 3: Authorization Response
Upon successful authorization, the user is redirected to yourredirect_uri with:
| Parameter | Description |
|---|---|
code | The authorization code (valid for 10 minutes) |
state | The state parameter you provided (verify this matches!) |
Token Endpoint
Step 4: Exchange Authorization Code for Access Token
| Parameter | Type | Required | Description |
|---|---|---|---|
grant_type | string | Yes | Must be authorization_code |
code | string | Yes | The authorization code received |
redirect_uri | string | Yes | Must match the authorization request |
client_id | string | Yes | Your OAuth client ID |
client_secret | string | Yes | Your OAuth client secret |
| Field | Description |
|---|---|
access_token | JWT access token for API requests |
token_type | Always Bearer |
expires_in | Token lifetime in seconds (3600 = 1 hour, null = permanent) |
scope | Granted scopes |
Using the Access Token
Once you have an access token, include it in theAuthorization header for all API requests:
Scopes
| Scope | Description |
|---|---|
offline_access | Request a permanent access token (never expires) |
- Standard tokens: Expire after 1 hour (
expires_in: 3600) - Offline access tokens: Never expire (
expires_in: null)
Error Handling
Common OAuth errors:| Error | Description |
|---|---|
invalid_request | The request is missing a required parameter or is malformed |
unauthorized_client | The client is not authorized to use this flow |
access_denied | The user denied the authorization request |
invalid_grant | The authorization code is invalid or expired |
invalid_client | Client authentication failed |

