Created
January 18, 2017 17:52
-
-
Save allthingsclowd/e0baade0c1524e0d5f5147fc32799494 to your computer and use it in GitHub Desktop.
Example snippet to rescope a k5 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_rescoped_token(k5token, projectid, region): | |
"""Get a regional project token - rescoped | |
Returns: | |
STRING: Regionally Scoped Project Token | |
Args: | |
k5token (TYPE): valid regional token | |
projectid (TYPE): project id to scope to | |
region (TYPE): k5 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": [ | |
"token" | |
], | |
"token": { | |
"id": k5token | |
} | |
}, | |
"scope": { | |
"project": { | |
"id": projectid | |
} | |
} | |
} | |
}) | |
return response | |
except: | |
return 'Regional Project Rescoping Failure' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment