Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@allthingsclowd
Created January 18, 2017 17:52
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/e0baade0c1524e0d5f5147fc32799494 to your computer and use it in GitHub Desktop.
Save allthingsclowd/e0baade0c1524e0d5f5147fc32799494 to your computer and use it in GitHub Desktop.
Example snippet to rescope a k5 token
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