Manual Integration
If you're not using an auth framework, you'll need to implement the OAuth 2.0 flow manually:
OAuth Flow
The ARES OAuth 2.0 flow follows these steps:
Your application redirects the user to ARES's authorization endpoint.
The user logs in to ARES and grants permission to your application.
ARES redirects back to your application with an authorization code.
Your application exchanges the authorization code for an access token.
Your application uses the access token to make API calls to ARES on behalf of the user.
OAuth Endpoints:
Authorization endpoint: https://joinares.com
Token Endpoint: https://oauth.joinares.com/oauth/token
User Endpoint: https://oauth.joinares.com/v1/user
1. Redirect users to the ARES authorization URL
REQUIRED: Replace ARES_CLIENT_ID, ARES_CLIENT_SECRET, and REDIRECT_URI with your credentials.
This redirection will send your user to log in on the ARES website and grant consent for your application to access their information. Once all that is done, the user will be redirected back to your website based on the redirect URI you provided along with the authorization code.
2. Handle the callback and exchange the authorization code for an access token
After the user authorizes your application, you'll receive an authorization code. The next step is to handle the authorization code that you receive from part 1 and exchange it for an access token.
Keep your
client_secret
confidential. Never expose it in client-side code or public repositories.The authorization code can only be used once. If you need to get a new access token later, use the refresh token flow.
Store the
refresh_token
securely. You'll need it to obtain new access tokens when the current one expires.
Response
If the request is successful, you'll receive a JSON response containing the access token, refresh token, and other details:
Example
3. Store the access token securely to use it for subsequent API calls.
After receiving the access token, you must store it securely for use in subsequent API calls. The method of storage depends on your application type and security requirements.
Important Considerations:
Security: Store the access token in a secure manner to prevent unauthorized access.
Application Type:
For server-side applications, consider using secure server-side storage solutions.
For client-side applications, use secure storage mechanisms provided by the platform.
Encryption: If storing the token locally, consider encrypting it.
Compliance: Ensure your storage method complies with relevant security standards and regulations.
4. Refresh the access token
Refresh token URL: https://oauth.joinares.com/oauth/token
Access tokens are designed to be short-lived for security reasons. When an access token expires (1 hour after issuance in our case), instead of requiring the user to log in again, you can use a refresh token to obtain a new access token.
To refresh your access token:
Send a POST request to the token endpoint.
Use the
refresh_token
grant type.Include your refresh token in the request body.
Example request:
This will return a new access token and refresh token pair. Always use the most recent refresh token for subsequent refresh requests.
Example response:
Note: Refresh tokens may also expire. If this happens, you'll need to re-authenticate the user through the full OAuth flow.
Last updated