curl --request POST \
--url https://accounts.eka.care/oauth2/token \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data grant_type=authorization_code \
--data code=ory_ac_example \
--data redirect_uri=http://localhost:50515/auth-success \
--data client_id=EC_178843954824934 \
--data client_secret=your_client_secret \
--data code_verifier=your_original_pkce_code_verifier{
"access_token": "ory_at_example",
"token_type": "bearer",
"expires_in": 3600,
"scope": "openid profile email offline_access",
"refresh_token": "ory_rt_example",
"id_token": "eyJhbGciOiJSUzI1NiIsImtpZCI6ImVrYS1lbXIifQ.example"
}{
"error": "invalid_grant",
"error_description": "The provided authorization grant is invalid, expired, or already used."
}{
"error": "invalid_grant",
"error_description": "The provided authorization grant is invalid, expired, or already used."
}APIs
Exchange Tokens
Exchanges a single-use authorization code for tokens, or exchanges a refresh token for a new token set.
Refresh tokens are rotated on every refresh: each successful
refresh_token grant returns a new refresh_token and invalidates the
one that was sent. Always persist the latest refresh token from the
response.
Send parameters as application/x-www-form-urlencoded, including
client_id and client_secret in the form body.
POST
/
oauth2
/
token
curl --request POST \
--url https://accounts.eka.care/oauth2/token \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data grant_type=authorization_code \
--data code=ory_ac_example \
--data redirect_uri=http://localhost:50515/auth-success \
--data client_id=EC_178843954824934 \
--data client_secret=your_client_secret \
--data code_verifier=your_original_pkce_code_verifier{
"access_token": "ory_at_example",
"token_type": "bearer",
"expires_in": 3600,
"scope": "openid profile email offline_access",
"refresh_token": "ory_rt_example",
"id_token": "eyJhbGciOiJSUzI1NiIsImtpZCI6ImVrYS1lbXIifQ.example"
}{
"error": "invalid_grant",
"error_description": "The provided authorization grant is invalid, expired, or already used."
}{
"error": "invalid_grant",
"error_description": "The provided authorization grant is invalid, expired, or already used."
}Use this endpoint from your backend to:
- Exchange an authorization code using
grant_type=authorization_code. - Refresh a token set using
grant_type=refresh_token.
code_verifier during the code exchange. A verifier is not used for the refresh-token grant.
Refresh tokens are rotated on every refresh. Each successful refresh_token grant returns a new
refresh_token and invalidates the one you sent, so always store the latest refresh token from the
response and use it for the next refresh. Reusing an old refresh token returns an invalid_grant error.Body
application/x-www-form-urlencoded
- Option 1
- Option 2
Response
Token response.
Was this page helpful?

