Skip to main content
The OAuth endpoints issue and revoke tokens for applications that act on behalf of Top.gg users. Read the authorization guide for the full flow. Both endpoints take application/x-www-form-urlencoded bodies and authenticate your application with its client ID and secret, either as form fields or as HTTP Basic authentication. Errors follow RFC 6749: a JSON body with error and an optional error_description.

POST /oauth2/token

Exchanges an authorization code for tokens, or refreshes an access token.

Authorization code grant

string
required
authorization_code
string
required
The code from the callback. Single use, expires after 60 seconds.
string
required
The same redirect_uri used in the authorization request.
string
required
The PKCE verifier whose SHA-256 hash was sent as code_challenge.
string
required
Your client ID. Can be sent via HTTP Basic authentication instead.
string
required
Your client secret. Can be sent via HTTP Basic authentication instead.

Refresh token grant

string
required
refresh_token
string
required
The refresh token from the previous token response. Each refresh token can be used once.
string
Space-separated subset of the granted scopes to narrow the new access token. Defaults to all granted scopes.
string
required
Your client ID.
string
required
Your client secret.

Response fields

string
required
Bearer token for v1 API requests.
string
required
Always Bearer.
number
required
Access token lifetime in seconds. Currently 604800.
string
required
New refresh token. Replace the stored one, the previous refresh token is no longer valid.
string
required
Space-separated scopes the access token carries.
object
The project the user granted. Only returned when exchanging an authorization code. Re-fetch anytime with GET /projects.

Example response

Error responses


POST /oauth2/revoke

Revokes an authorization. Pass the refresh token. Every access token issued for the same authorization stops working as well.
string
required
The refresh token to revoke.
string
Optional, refresh_token. Accepted for compatibility with RFC 7009.
string
required
Your client ID.
string
required
Your client secret.

Response

Always returns 200 OK with an empty body, including when the token is unknown or already revoked.