Issuing access tokens

This section describes the procedure for issuing access tokens.

Prerequisites

  1. You must have a basic authorization header that was issued as a result of the credential creation.

Access Token Issuance Procedure

  1. Run the terminal.

  2. Use the basic authorization header to request the ChainZ API authorization server to issue an access token.

# Example of Request for Issuance of Access Token
curl 'https://iam.chainz.biz/auth/realms/chainz/protocol/openid-connect/token' \
  -H 'Authorization: {Basic_Authorization_Header}' \
  --data-raw 'grant_type=client_credentials'
# Example of Request for Issuance of Access Token - Response
{
  "access_token": "{access token}",
  "expires_in": 300,
  "refresh_expires_in": 0,
  "token_type": "Bearer",
  "not-before-policy": 0,
  "scope": "opera-scope profile email"
}

Troubleshooting

1. unauthorized_client

If you enter an invalid basic authorization header, you will see the result of an 'unauthorized_client' error as follows:

# Invalid Input Example - Request
curl 'https://{ChainZ API authorization server URL} /auth/realms/chainz/protocol/openid-connect/token' \
 -H 'Authorization: {Invalid Basic Authorization Header} ' \
  --data-raw 'grant_type=client_credentials'
{"error":"unauthorized_client","error_description":"Invalid client secret"}
# Invalid Input Example - Request
{
  "error": "unauthorized_client",
  "error_description": "Invalid client secret"
}

2. URL using bad/illegal format or missing URL

When entering curl in the terminal, if there is a space after a backslash (), you will receive a message in Response stating that the URL is bad or missing (URL using bad/invalid format or missing URL).

# If there is a space after a backslash - Request
$ curl 'https://iam.chainz.biz/auth/realms/chainz/protocol/openid-connect/token' \ 
# If there is a space after a backslash - Response
{"error":"RESTEASY003650: No resource method found for GET, return 405 with Allow header"}
curl: (3) URL using bad/illegal format or missing URL

Last updated