Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save JorgeFrancoIbanez/6b66cabf0be84a3e1869408a9bfd6d7a to your computer and use it in GitHub Desktop.
Save JorgeFrancoIbanez/6b66cabf0be84a3e1869408a9bfd6d7a to your computer and use it in GitHub Desktop.
Auth by token to keystone openstackRequire requests
import requests
import json
auth_payload = {
"auth": {
"identity": {
"methods": [
"token"
],
"token": {
"id": "TokenID"
}
},
"scope": {
"system": {
"all": "true"
}
}
}
}
def get_auth():
token_url = 'https://<Openstack-API-URL>:<Keystone-PORT>/v3/auth/tokens'
payload = json.dumps(auth_payload)
headers = {"Accept": "application/json", "Content-Type": "application/json"}
res = requests.post(token_url, data=payload, headers=headers)
return res
def main():
authentication_token=get_auth().json()
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment