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:

  1. Your application redirects the user to ARES's authorization endpoint.

  2. The user logs in to ARES and grants permission to your application.

  3. ARES redirects back to your application with an authorization code.

circle-info

E.g. If your redirect_uri is set to "www.example.com", the redirection will be to "www.example.com/?code=authorization_code_here&state=state"

  1. Your application exchanges the authorization code for an access token.

  2. Your application uses the access token to make API calls to ARES on behalf of the user.

OAuth Endpoints:

Authorization endpoint: https://joinares.com/oauth

Token Endpoint: https://oauth.joinares.com/oauth/token

User Endpoint: https://oauth.joinares.com/v1/user

1. Redirect users to the ARES authorization URL

circle-exclamation

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.

circle-info

E.g. If your redirect_uri is set to "www.example.com", the redirection will be to "www.example.com/?code=authorization_code_here&state=state"

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.

triangle-exclamation

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:

  1. Security: Store the access token in a secure manner to prevent unauthorized access.

  2. 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.

  3. Encryption: If storing the token locally, consider encrypting it.

  4. Token Lifespan: Remember that access tokens are typically short-lived. Implement proper token refresh mechanisms.

  5. Usage: When making API calls, include the access token in the Authorization header:

  6. Compliance: Ensure your storage method complies with relevant security standards and regulations.

circle-info

The specific implementation of token storage is up to you and should be tailored to your application's architecture and security requirements. Always prioritize the security of your users' data and follow best practices for your chosen platform and technology stack.

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.

When you initially authenticate, you receive both an access token and a refresh token (example)

To refresh your access token:

  1. Send a POST request to the token endpoint.

  2. Use the refresh_token grant type.

  3. 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:

circle-exclamation

Last updated