Get Access Token for a Service Account

If you want to get the access token for a service account manually you can do this by sending an http post request to Keycloak. You can use a simple python script for this:

import os
import requests

SA_ID = os.environ['SA_ID']
SA_SECRET = os.environ['SA_SECRET'] 

data = {"grant_type": {"client_credentials"}, "client_id": SA_ID, "client_secret": SA_SECRET}
response = requests.post('https://auth.vseth.ethz.ch/auth/realms/VSETH/protocol/openid-connect/token', data)
access_token = response.json()['access_token'] 
print(access_token)