For the authorization / access code endpoints, please refer to Manual Integration
User Info Endpoint
The user info endpoint is used to retrieve the user object, which includes the user's id, email, and credits left.
This endpoint requires an access token that you received from the OAuth process. Each token has a specific user tied to it.
URL: https://oauth.joinares.com/v1/user
A short note/description on what the usage is about. This should stay consistent with each usage if it's on the same thing. (Ex. "video generation", "editing 1 video", etc.) Line Item.
credits
Yes
number
The number of credits to deduct from the user's ARES account for this usage.
There's no need to include additional information about the user because we will take that information from the access token in the header.
{
"error": "No token provided" // Token not detected in the auth header
},
{
"error": "Invalid token" // Token doesn't exist or is expired.
} // If token is expired, try refreshing the token
{
"error": "Token expired"
}
// IMPORTANT: Must always include the access token at the header.
// Fetch request in Javascript
fetch('https://oauth.joinares.com/v1/user', {
method: 'GET',
headers: {
'Authorization': `Bearer ${accessToken}`, // Required access token in header
'Content-Type': 'application/json'
}
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
POST https://oauth.joinares.com/v1/user
Authorization: Bearer USER_ACCESS_TOKEN // Replace with the real access token
// IMPORTANT: Must always include the access token at the header.
const accessToken = 'USER_ACCESS_TOKEN'; // Replace this value
// Fetch request in Javascript
fetch('https://oauth.joinares.com/v1/partner/usage', {
method: 'POST',
headers: {
'Authorization': `Bearer ${accessToken}`, // Required access token in header
'Content-Type': 'application/json'
},
body: JSON.stringify({
"client_id": ARES_CLIENT_ID, // Replace with your client ID
"usage": USAGE_INFO, // Replace with a note on what the user is trying to use
"credits": NUMBER_OF_CREDITS // Replace with the number of credits the usage will cost the user
})
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
POST https://oauth.joinares.com/v1/partner/usage
Authorization: Bearer ${accessToken} //Replace with actual token
Content-Type: application/json
{
"client_id": ARES_CLIENT_ID, // Replace with your client ID
"usage": USAGE_INFO, // Replace with a note on what the user is trying to use
"credits": NUMBER_OF_CREDITS // Replace with the number of credits the usage will cost the user
}