OAuth2 Authentication
How to obtain and use access tokens to consume the Nuvy API
The Nuvy API uses OAuth2 with the Client Credentials flow for authentication. Your application exchanges its credentials (client_id and client_secret) for a time-limited access token, which is then included in every API request.
Nuvy will provide you with a pair of credentials:
| Parameter | Description |
|---|---|
| client_id | Your application's unique identifier |
| client_secret | Your application's secret key |
Send a POST request to the token endpoint using Basic Authentication. The client_id and client_secret are Base64-encoded in the Authorization header:
Or, using the curl shorthand for Basic Auth:
A successful request returns a JSON response with the access token:
| Field | Description |
|---|---|
| access_token | The JWT token to use in API requests |
| token_type | Always "Bearer" |
| expires_in | Token lifetime in seconds |
Include the access token in the Authorization header of every API request:
Node.js
Python
Java
Tokens are short-lived. Your application should:
- Cache the token and reuse it until it expires
- Monitor the expires_in value and request a new token before expiration
- Handle 401 responses by requesting a fresh token and retrying the request
| Status | Description | Action |
|---|---|---|
| 400 | Invalid request (missing or wrong grant_type) | Check that grant_type=client_credentials |
| 401 | Invalid credentials | Verify client_id and client_secret |
- Store credentials in environment variables or a secrets manager, never in source code
- Use HTTPS for all requests (enforced by Nuvy API)
- Rotate your client_secret periodically
- Implement token caching to minimize token requests
- Never log access tokens or credentials
| Environment | Token Endpoint |
|---|---|
| QA | https://qa.api.nuvy.ai/oauth2/token |
| Production | https://prd.api.nuvy.ai/oauth2/token |
API Reference
Technical specification for the OAuth2 token endpoint
Returns an access token using the OAuth2 client credentials flow. Requires Basic authentication with client_id and client_secret.
Authentication
| Type | Details |
|---|---|
| Basic Auth | Base64 encoded client_id:client_secret |
Headers
| Header | Value | Required |
|---|---|---|
| Content-Type | application/x-www-form-urlencoded | Yes |
| Authorization | Basic {base64(client_id:client_secret)} | Yes |
Request Body
| Parameter | Type | Required | Description |
|---|---|---|---|
| grant_type | string | Yes | Must be client_credentials |
Response (200 OK)
Error Responses
| Status | Meaning |
|---|---|
| 400 Bad Request | Invalid or missing grant_type parameter |
| 401 Unauthorized | Invalid client_id or client_secret |
curl Generator
Enter your credentials to generate a ready-to-use curl command. Copy and run it in your terminal.