Exchange an identity provider-signed token for a State Backed token
Once you have configured at least one identity provider (by posting to /idps) and at least one token provider (by posting to /token-providers), you can exchange any identity provider token for a token generated by one of your token providers.
This allows you to have completely secure, end-to-end authorization with your State Backed machine instances without any server-side code while using your identity provider of choice.
This endpoint should generally conform to https://datatracker.ietf.org/doc/html/rfc8693
Body
Exchange an identity provider-signed token for a State Backed token.
-
The type of grant being requested
Value is
urn:ietf:params:oauth:grant-type:token-exchange
. -
Identifies the token provider service to use to generate the token.
Must be of the form:
https://tokens.statebacked.dev/<your-org-id>/<token-provider-service-id>
Where
your-org-id
can be found viasmply orgs list
andtoken-provider-service-id
is theservice
that you passed in your post to /token-providers. -
requested_token-type string
The type of token being requested
Value is
urn:ietf:params:oauth:token-type:access_token
. -
A JWT signed by one of your configured identity providers (based on configurations posted to /idps)
curl \
-X POST https://api.statebacked.dev/tokens \
-H "Content-Type: application/x-www-form-urlencoded" \
-d 'grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Atoken-exchange&audience=https%3A%2F%2Ftokens.statebacked.dev%2Forg_yourorg%2Fyour-service&requested_token-type=urn%3Aietf%3Aparams%3Aoauth%3Atoken-type%3Aaccess_token&subject_token=string'
{
"grant_type": "urn:ietf:params:oauth:grant-type:token-exchange",
"audience": "https://tokens.statebacked.dev/org_yourorg/your-service",
"requested_token-type": "urn:ietf:params:oauth:token-type:access_token",
"subject_token": "string"
}
{
"grant_type": "urn:ietf:params:oauth:grant-type:token-exchange",
"audience": "https://tokens.statebacked.dev/org_yourorg/your-service",
"requested_token-type": "urn:ietf:params:oauth:token-type:access_token",
"subject_token": "string"
}
{
"access_token": "string",
"issued_token_type": "urn:ietf:params:oauth:token-type:access_token",
"token_type": "Bearer"
}
{
"access_token": "string",
"issued_token_type": "urn:ietf:params:oauth:token-type:access_token",
"token_type": "Bearer"
}