Skip to content

Instantly share code, notes, and snippets.

@brianv0
Created March 29, 2018 22:46
Show Gist options
  • Save brianv0/8c735216e9e13b98932db3da3008fbc9 to your computer and use it in GitHub Desktop.
Save brianv0/8c735216e9e13b98932db3da3008fbc9 to your computer and use it in GitHub Desktop.
Dump Token
import requests
import json
import jwt
url = "https://example.com/protected/stuff/blah"
scope = ["write:/stuff", "read:mysql://lsst-qserv:4040/"]
subject = "bvan"
demo_json = {
"payload": {
'scp': scope,
'aud': "",
'sub': subject
},
"header": {
'alg': 'RS256',
'typ': 'JWT'
}
}
data = json.dumps({
'payload': json.dumps(demo_json['payload']),
'header': json.dumps(demo_json['header'])
})
head = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36','Content-Type': 'application/json'}
r = requests.post("https://demo.scitokens.org/issue", data = data, headers = head)
unverified_payload = jwt.decode(r.text, verify=False, algorithms=['RS256'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment