Created
June 12, 2019 20:17
-
-
Save JorgeFrancoIbanez/6b66cabf0be84a3e1869408a9bfd6d7a to your computer and use it in GitHub Desktop.
Auth by token to keystone openstackRequire requests
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
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