diff options
author | Lars Wirzenius <liw@liw.fi> | 2018-02-09 13:53:33 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2018-02-09 13:56:43 +0200 |
commit | f1f291b270b96fe1511286cb807f02c9741b0d71 (patch) | |
tree | 509a7f697685e9282fbdc6838fb037ff6cb5e4dd /qvisqve-get-token | |
parent | 3b208da0461f5a129fcbc527fbfdd9ed8309d077 (diff) | |
download | qvisqve-f1f291b270b96fe1511286cb807f02c9741b0d71.tar.gz |
Rename: to Qvisqve
Diffstat (limited to 'qvisqve-get-token')
-rwxr-xr-x | qvisqve-get-token | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/qvisqve-get-token b/qvisqve-get-token new file mode 100755 index 0000000..8068585 --- /dev/null +++ b/qvisqve-get-token @@ -0,0 +1,28 @@ +#!/usr/bin/env python3 + + +import sys + + +import requests + + +baseurl, user, secret = sys.argv[1:4] +scopes = sys.argv[4:] + + +url = '{}/token'.format(baseurl) +auth = (user, secret) +data = { + 'grant_type': 'client_credentials', + 'scope': ' '.join(scopes), +} + +r = requests.post(url, auth=auth, data=data, verify=False) +if r.ok: + obj = r.json() + print(obj['access_token']) +else: + sys.stderr.write(r.text) + sys.stderr.write('\n') + sys.exit(1) |