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."
}Eka OIDC Provider
Exchange Tokens
Exchanges a single-use authorization code for tokens, or exchanges a refresh token for a new token set.
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.Body
application/x-www-form-urlencoded
- Option 1
- Option 2
Available options:
authorization_code Short-lived, single-use code returned by /oauth2/authorize.
Must exactly match the URI used in the authorization request.
Client identifier issued by Eka.
Client secret issued by Eka.
Original PKCE verifier. Required when the authorization request used PKCE.
Required string length:
43 - 128Response
Token response.
Bearer token used to authorize Eka API requests.
Example:
"bearer"
Access-token lifetime in seconds.
Space-separated scopes granted to the token.
Token used to obtain a new token set.
OpenID Connect ID token returned when openid was granted.
Was this page helpful?

