Skip to content

Exchange an OIDC token for a ZapWorks token

POST
/auth/token
curl --request POST \
--url https://example.com/v1/auth/token \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data grant_type=urn:ietf:params:oauth:grant-type:token-exchange \
--data subject_token=example \
--data subject_token_type=urn:ietf:params:oauth:token-type:id_token \
--data requested_token_type=urn:ietf:params:oauth:token-type:access_token

Exchanges a token from an OIDC provider that ZapWorks trusts for a ZapWorks token, which can then be used to call the rest of the API. It follows OAuth 2.0 Token Exchange (RFC 8693), so OAuth client libraries can call it directly. It needs no Authorization header.

object
grant_type
required
Allowed value: urn:ietf:params:oauth:grant-type:token-exchange
subject_token
required

The token from the OIDC provider.

string
subject_token_type
required

What kind of token subject_token is - usually an ID token.

string
Allowed values: urn:ietf:params:oauth:token-type:id_token urn:ietf:params:oauth:token-type:jwt urn:ietf:params:oauth:token-type:access_token
requested_token_type

The kind of token wanted. Only access tokens are issued.

Allowed value: urn:ietf:params:oauth:token-type:access_token

The ZapWorks token

Media typeapplication/json
object
access_token
required

The ZapWorks token.

string
issued_token_type
required
Allowed value: urn:ietf:params:oauth:token-type:access_token
token_type
required
Allowed value: Bearer
expires_in

How many seconds the token is valid for.

integer

Example

{
"issued_token_type": "urn:ietf:params:oauth:token-type:access_token",
"token_type": "Bearer"
}

The request is invalid

Media typeapplication/json

An error in the form OAuth token endpoints use.

object
error
required

The kind of error, e.g. invalid_request or unsupported_grant_type.

string
error_description
string

Example generated

{
"error": "example",
"error_description": "example"
}

Exchanging tokens isn’t available yet

Media typeapplication/json

An error in the form OAuth token endpoints use.

object
error
required

The kind of error, e.g. invalid_request or unsupported_grant_type.

string
error_description
string

Example generated

{
"error": "example",
"error_description": "example"
}