Snippet of python API call to get a regional Project scoped token
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_scoped_token(adminUser, adminPassword, contract, projectid, region): | |
"""Summary - Get a regional project scoped token using a username and password | |
Returns: | |
Object: Regionally Scoped Project Token Object | |
Args: | |
adminUser (TYPE): username | |
adminPassword (TYPE): password | |
contract (TYPE): contract name | |
projectid (TYPE): project id | |
region (TYPE): region | |
""" | |
identityURL = 'https://identity.' + region + \ | |
'.cloud.global.fujitsu.com/v3/auth/tokens' | |
try: | |
response = requests.post(identityURL, | |
headers={'Content-Type': 'application/json', | |
'Accept': 'application/json'}, | |
json={"auth": | |
{"identity": | |
{"methods": ["password"], "password": | |
{"user": | |
{"domain": | |
{"name": contract}, | |
"name": adminUser, | |
"password": adminPassword | |
}}}, | |
"scope": | |
{"project": | |
{"id": projectid | |
}}}}) | |
return response | |
except: | |
return 'Regional Project Token Scoping Failure' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment