OAuth Tokens
After you create a client (see quickstart), the /api/token
and /api/refresh
endpoints let you get a refresh token for each user, as well as an access token whenever you need it.
Get a Refresh Token
- Name
code
- Type
- string
- Description
Authorization code you received after the user authorized your client. See quickstart for more details.
- Name
client_id
- Type
- string
- Description
ID you received after creating a client. Visit clients if you forgot it.
- Name
client_secret
- Type
- string
- Description
Secret key you received after creating a client. If you lost it, please contact us on our Discord.
- Name
redirect_uri
- Type
- string
- Description
Redirect URI that you use to generate the auth code. Specified when you created your client.
Request
curl -G https://api.onetwentyone.ai/api/token \
-d '{"code": "users_auth_code"}"' \
-d '{"client_id": "your_client_id"}"' \
-d '{"client_secret": "your_client_secret"}' \
-d '{"redirect_uri": "your_redirect_uri"}'
Response
{
"access_token": "your_access_token",
"refresh_token": "your_refresh_token",
}
This access token expires in 1 hour, but the refresh token doesn't expire.
Exchange Refresh for Access Token
- Name
refresh_token
- Type
- string
- Description
Refresh token you got from
/api/token
.
- Name
client_id
- Type
- string
- Description
ID you received after creating a client. Visit clients if you forgot it.
- Name
client_secret
- Type
- string
- Description
Secret key you received after creating a client. If you lost it, please contact us on our Discord.
- Name
user_id
- Type
- string
- Description
The user_id associated with the refresh token.
Request
curl -G https://api.onetwentyone.ai/api/refresh \
-d '{"refresh_token": "refresh_token received from `/api/token`"}"' \
-d '{"client_id": "your_client_id"}"' \
-d '{"client_secret": "your_client_secret"}' \
-d '{"user_id": "user_id associated with the refresh token"}'
Response
{
"access_token": "your_access_token",
"expires_in": 3600,
}
This access token expires in 1 hour, but the refresh token doesn't expire.