Getting Started
This guide will help you set up and start using the Fanbase API in a few steps.
Prerequisites
- Access credentials provided by Fanbase (client_id and client_secret)
- A redirect URI configured and agreed with Fanbase (only for SSO authentication)
- Development environment configured to make HTTP requests
Step 1: Get Credentials
Contact the Fanbase team to obtain your authentication credentials:
- client_id: Public identifier for your client
- client_secret: Secret that must be kept confidential
Step 2: Choose Integration Type
Fanbase offers different types of integration:
SSO Authentication (Single Sign-On)
For user authentication through OAuth 2.0 flow:
- Configure the redirect URI with Fanbase
- Implement the authorization flow
- Use Security endpoints to get user information
Connect Integrations
For integrations and data processing:
- Get token using client_credentials
- Use Connect API endpoints
- Process data through queues or direct integrations
Fanmarket
For integration with delivery services:
- Configure Melhor Envio integration
- Use freight calculation and management services
Step 3: Configure Redirect URI (Only for SSO)
If you will use SSO authentication, define together with Fanbase what your redirect URI (redirect_uri) will be. This URI determines the address to which authentication request responses will be directed.
Example:
https://your-domain.com.br/callbackStep 4: Get Access Token
For SSO Authentication
The basic authentication flow consists of:
- Redirect user to the authorization endpoint
- Receive the authorization code in the callback
- Exchange the code for tokens through the token endpoint
- Validate and use tokens as needed
Quick Example:
javascript
const authUrl = `{login-producao}/authorize?response_type=code&scope=openid profile&client_id=your_client_id&redirect_uri=https://your-domain.com.br/callback`;
window.location.href = authUrl;For Connect Integrations
Get token using client_credentials:
javascript
const response = await fetch('{security-producao}/api/token?grant_type=client_credentials&client_id=your_client_id&client_secret=your_client_secret', {
method: 'POST'
});
const { access_token } = await response.json();