Skip to content
Skip to Content
Coder Docs

OAuth2 token exchange.

POST
/oauth2/tokens

Request Body

application/x-www-form-urlencoded
  1. body
client_id?string

Client ID, required if grant_type=authorization_code

client_secret?string

Client secret, required if grant_type=authorization_code and the client is confidential. Public clients (token_endpoint_auth_method=none) send no secret.

code?string

Authorization code, required if grant_type=authorization_code

code_verifier?string

PKCE code verifier, required if grant_type=authorization_code. 43-128 characters per RFC 7636.

refresh_token?string

Refresh token, required if grant_type=refresh_token

grant_type*string

Grant type

Value in"authorization_code""refresh_token""password""client_credentials""implicit"

Response Body

OK

application/json
  1. response
access_token?string
expires_in?integer
expiry?string

Expiry is not part of RFC 6749 but is included for compatibility with golang.org/x/oauth2.Token and clients that expect a timestamp.

Formatdate-time
refresh_token?string
scope?string
token_type?codersdk.OAuth2TokenType
Value in"Bearer""DPoP"

The samples read CODER_URL and CODER_SESSION_TOKEN: set up your environment.

curl -X POST \	"$CODER_URL/oauth2/tokens" \	-H "Content-Type: application/x-www-form-urlencoded" \	--data-binary "@{file}"
Example Response
{  "access_token": "string",  "expires_in": 0,  "expiry": "2019-08-24T14:15:22Z",  "refresh_token": "string",  "scope": "string",  "token_type": "Bearer"}