Comment on page

Generate token

We can authenticate with the registry as a particular entity to perform operations like retrieving, searching, updating and attesting.

Request

To authenticate as an entity, we need to make the following request:
post
http:/keycloak-url/auth/realms/{realm}/protocol/openid-connect/token
Important variables in the response body:
Field
In
Type
Description
access_token
body
string
Access token used to retrieve/update entity
expires_in
body
number
Number of seconds before the access token will be declared invalid
token_type
body
string
Should be Bearer, else we have gotten the wrong token
scope
body
string
Using this token, what information we can access about the entity

Usage

cURL

curl --location \
--request POST \
--header 'content-type: application/x-www-form-urlencoded' \
--data 'client_id=registry-frontend' \
--data 'username={username}' \
--data 'password=test' \
--data 'grant_type=password' \
'{keycloak-url}/auth/realms/{realm}/protocol/openid-connect/token'

HTTPie

http --form post \
'{keycloak-url}/auth/realms/{realm}/protocol/openid-connect/token' \
'content-type: application/x-www-form-urlencoded' \
'client_id=registry-frontend' \
'username={username}' \
'password=test' \
'grant_type=password'
{keycloak-url} is usually http://localhost:8080, and {realm} is usually sunbird-rc.
The {keycloak-url} is usually localhost:{port}. The port can be found under the keycloak section in the docker-compose.yml file. The {realm} can be found at the top of the realm-export.json file used to configure keycloak.