Authentication
Authentication for FinHub API integration
Authentication
All FinHub APIs use OAuth 2.0 for authentication and authorization. This document explains how to authenticate with the FinHub API services.
Overview
FinHub uses the OAuth 2.0 Client Credentials flow for tenant authentication. This flow is designed for server-to-server API calls where the tenant application acts on its own behalf rather than on behalf of a specific user.
Prerequisites
Before you can authenticate with the FinHub APIs, you need:
- A tenant account with FinHub
- Client credentials (client ID and client secret) provided during the tenant onboarding process
- Appropriate capability codes (SCT01, SCT02, etc.) enabled for your tenant account
OAuth 2.0 Client Credentials Flow
Step 1: Request an Access Token
To obtain an access token, make a POST request to the token endpoint:
Step 2: Receive the Access Token
If the credentials are valid, the authorization server will respond with an access token:
Step 3: Use the Access Token
Include the access token in the Authorization header of your API requests:
Token Lifecycle
- Access tokens are valid for 1 hour (3600 seconds)
- You should request a new token when the current one expires
- Do not share tokens between different applications or environments
Environment-Specific Authentication
FinHub provides separate authentication endpoints for each environment:
- Sandbox:
https://auth.sandbox.finhub.com/oauth2/token
- Production:
https://auth.finhub.com/oauth2/token
Always use the appropriate endpoint for your current environment.
Security Best Practices
- Secure Storage: Store client secrets securely and never expose them in client-side code
- Token Management: Implement proper token caching and refresh mechanisms
- TLS/SSL: Always use HTTPS for all API communications
- IP Restrictions: Consider restricting API access to specific IP addresses
- Minimal Scope: Request only the scopes your application needs
Troubleshooting
Common authentication errors:
- 401 Unauthorized: Invalid or expired access token
- 403 Forbidden: Valid token but insufficient permissions
- 400 Bad Request: Malformed authentication request
If you encounter persistent authentication issues, contact FinHub Support with your tenant ID and detailed error information.