Use Token
The Use Token endpoint exchanges the authorization code you received from a Use AgeKey request (when using the agekey-upgrade scope and all age thresholds are false) for an access token. This access token is used to authorize the upgrade request.
OAuth 2.0 Specification
This endpoint implements the OAuth 2.0 Token Endpoint for authorization code exchange.
Token endpoint
- cURL
- JavaScript
- Python
curl -X POST "https://api.agekey.org/v1/oidc/use/token" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Authorization: Basic <base64(client_id:client_secret)>" \
-d "grant_type=authorization_code" \
-d "code=your-authorization-code"
const axios = require('axios');
const qs = require('querystring');
const clientId = 'your-client-id';
const clientSecret = 'your-client-secret';
const credentials = Buffer.from(`${clientId}:${clientSecret}`).toString('base64');
const formData = {
grant_type: 'authorization_code',
code: 'your-authorization-code'
};
const response = await axios.post(
'https://api.agekey.org/v1/oidc/use/token',
qs.stringify(formData),
{
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Authorization': `Basic ${credentials}`
}
}
);
import requests
import base64
client_id = 'your-client-id'
client_secret = 'your-client-secret'
credentials = base64.b64encode(
f'{client_id}:{client_secret}'.encode()
).decode()
form_data = {
'grant_type': 'authorization_code',
'code': 'your-authorization-code'
}
response = requests.post(
'https://api.agekey.org/v1/oidc/use/token',
data=form_data,
headers={
'Content-Type': 'application/x-www-form-urlencoded',
'Authorization': f'Basic {credentials}'
}
)
Headers
| Header | Value | Required |
|---|---|---|
Content-Type | application/x-www-form-urlencoded | Yes |
Authorization | Basic <base64(client_id:client_secret)> | Yes |
Body
| Property | Type | Required | Description |
|---|---|---|---|
grant_type | string | Yes | Always set to authorization_code |
code | string | Yes | The authorization code returned from the Use AgeKey request when using agekey-upgrade scope and all thresholds are false |
Response
On success, returns an object with the access_token property. This access token can be used to authorize the upgrade request to the /v1/agekey/upgrade endpoint.
{
"access_token": "eyJhbGc...",
"token_type": "Bearer",
"expires_in": 3600
}
warning
Important: The access_token expires in 3600 seconds (1 hour). You should use it promptly for the upgrade request.