Commit 89ca6d55 authored by jackie / Andrea Ida Malkah Klaura's avatar jackie / Andrea Ida Malkah Klaura
Browse files

add tank package with session module

parent aa272684
import requests
def get_session_token (cfg, access_token):
"""
Retrieves a session token from tank, by using an access token previously
received from steering.
"""
headers = {"User-Agent": cfg["user_agent"]}
if cfg["verbosity"] >= 1:
print("[tank]: sending access token to session endpoint")
url = cfg["tank_base"] + cfg["tank_session_endpoint"]
headers["Authorization"] = "Bearer " + access_token
payload = {
"backend": "oidc",
"arguments": {
"access_token": access_token,
"token_type": "Bearer",
},
}
try:
response = requests.post(url, headers=headers, json=payload)
except:
e = sys.exc_info()
print(e[0].__name__, ':', e[1])
sys.exit(1)
if cfg["verbosity"] >= 2:
print("tank session:", response.json())
return response.json()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment