Skip to content

Instantly share code, notes, and snippets.

@allthingsclowd
Created January 18, 2017 17:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save allthingsclowd/72f7e7e5b39dc9a24380e6f0ce589557 to your computer and use it in GitHub Desktop.
Save allthingsclowd/72f7e7e5b39dc9a24380e6f0ce589557 to your computer and use it in GitHub Desktop.
Snippet of python API call to get a regional Project scoped token
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