Skip to content

Exchange the code for the user reference

OpenAPI JSON
POST
/connect/token
curl --request POST \
--url https://api.eu.apigami.com/connect/token \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "grant_type": "authorization_code", "code": "q4HcV7yO1c3uXn0mJ2rT8kLwZp5sA6dE9fG0hI1jK2l", "code_verifier": "dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk", "redirect_uri": "https://example.com/apigami/callback" }'

Your server trades the code the user came back with, within 60 seconds and once, for the user’s user_ref. Send the code_verifier whose challenge opened the connection and the same redirect_uri, character for character. Any failure is invalid_grant and burns the code: start a new connection.

Media typeapplication/json
object
grant_type

Optional; anything else is unsupported_grant_type.

Allowed value: authorization_code
code
required
string
code_verifier
required
string
/^[A-Za-z0-9._~-]{43,128}$/
redirect_uri
required
string format: uri
Example
{
"grant_type": "authorization_code",
"code": "q4HcV7yO1c3uXn0mJ2rT8kLwZp5sA6dE9fG0hI1jK2l",
"code_verifier": "dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk",
"redirect_uri": "https://example.com/apigami/callback"
}

The user is connected to your app. Save user_ref; install_ref is the browser the user connected from, or null.

Media typeapplication/json
object
user_ref
required
string
install_ref
required
string | null
installs
required
Array<object>
object
install_ref
required
string
label
required

The name the user gave that browser.

string | null
online
required
boolean
Example
{
"user_ref": "usr_3f9c1a0e7b2d4c58a61e9f0b2d7c4e13",
"install_ref": "ins_8b1e4f2a9c3d4e5f8a7b6c5d4e3f2a1b",
"installs": [
{
"install_ref": "ins_8b1e4f2a9c3d4e5f8a7b6c5d4e3f2a1b",
"label": null,
"online": true
}
]
}

The code cannot be exchanged.

Media typeapplication/json
object
error
required
string
consentPending

Present and true when the approval window is open and the user has not answered within 45 s.

boolean
Examples
{
"error": "invalid_grant"
}

Missing, malformed or revoked API key.

Media typeapplication/json
object
error
required
string
consentPending

Present and true when the approval window is open and the user has not answered within 45 s.

boolean
Example
{
"error": "bad client credentials"
}