I’m trying to use Daml Hub service account login to retrieve access tokens so that I don’t have to refresh the token in every 24 hours.
I’m using the requests Python library and implemented this try/except expression because the service account endpoint call fails with 502 error in the majority of cases (not always):
SA_LOGIN = f"https://{HUB_LEDGER_ID}.daml.app:443/.hub/v1/sa/login"
response = requests.post(SA_LOGIN, auth=('cred-XXXXXXXXXXXXXX', 'XXXXXXXXXXXXXX'))
try:
EVERLY_TOKEN = response.json()['token']
print("Service account token exchange successful")
except:
print("Service account token exchange didn't succeed, fetch token manually")
EVERLY_TOKEN = input("Insert Everly token ")
Am I doing something wrong?