How to generate keycloak token on CREODIAS

a) Using web browser console
Open your web browser and enter https://finder.creodias.eu/www/ in the address field.

Click on Log In button located in the upper-right-corner.

Fill in the blanks with your e-mail address and password.

Press “Login”.

Click somewhere on the site with the right mouse button and choose “Inspect Element”.

Change your view side from Inspector to Console.

Click on the white space beside the blue arrow to start typing.

Type in keycloak.token and press enter in order to generate your token.

b) By query with cURL
This case has already been presented in article: How to order products using Finder API on CREODIAS.
CURL is a tool to send data to the server using several protocols such as HTTP. In this example, the output is being filtered by grep and awk commands to obtain a token. In the Linux operating system it’s being seen as environmental variable KEYCLOAK_TOKEN.
export KEYCLOAK_TOKEN=$(curl -d 'client_id=CLOUDFERRO_PUBLIC' \
-d "username=${OS_USERNAME}" \
-d "password=${OS_PASSWORD}" \
-d 'grant_type=password' \
'https://identity.cloudferro.com/auth/realms/DIAS/protocol/openid-connect/token' | \
python3 -m json.tool | grep "access_token" | awk -F\" '{print $4}')
c) By Python script
import json
import requests
def get_keycloak(username: str, password: str) -> str:
data = {
"client_id": "CLOUDFERRO_PUBLIC",
"username": username,
"password": password,
"grant_type": "password",
}
try:
r = requests.post(
"https://identity.cloudferro.com/auth/realms/DIAS/protocol/openid-connect/token",
data=data,
)
r.raise_for_status()
except Exception as e:
raise Exception(
f"Keycloak token creation failed. Reponse from the server was: {r.json()}"
)
return r.json()["access_token"]
keycloak_token = get_keycloak(username, password)