import json as json_tool import requests import tool TOKEN_FETCH_URL = "/api/v1/test-token" def fetch_dbaas_token(cfg, email): central_url_prefix = cfg.get('environment').get('central_url_prefix') nightly_auth_key = cfg.get('auth').get('auth_secret_key') auth_body = dict( auth0_client_secret=cfg.get('auth').get('auth0_client_secret'), auth0_client_id=cfg.get('auth').get('auth0_client_id'), auth0_domain=cfg.get('auth').get('auth0_domain'), email=email ) auth_body["auth0_client_secret"] = tool.load_auth_from_k8s_secret(cfg.get('auth').get('central_auth_secret'), cfg.get('common').get('namespace'), nightly_auth_key) r = requests.post(central_url_prefix + TOKEN_FETCH_URL, json=auth_body) token_response = json_tool.loads(r.text) return "Bearer " + token_response['token']