In the code below, what is the lifetime of the generated token (keycloak_token
) or what is the maximum permitted number of requests by keycloak_token
?
import requests
def get_keycloak(username: str, password: str) -> str:
data = {
"client_id": "cdse-public",
"username": "---",
"password": "---",
"grant_type": "password",
}
try:
r = requests.post("https://identity.dataspace.copernicus.eu/auth/realms/CDSE/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")