Skip to content

Instantly share code, notes, and snippets.

@salrashid123
Created March 30, 2018 04:50
Show Gist options
  • Save salrashid123/0baa3a876fbd6acbcfe8ac04c0c22b0b to your computer and use it in GitHub Desktop.
Save salrashid123/0baa3a876fbd6acbcfe8ac04c0c22b0b to your computer and use it in GitHub Desktop.
svc_exchange.py
url = 'https://accounts.google.com/o/oauth2/token'
data = {'grant_type' : 'assertion',
'assertion_type' : 'http://oauth.net/grant_type/jwt/1.0/bearer',
'assertion' : signed_jwt }
headers = {"Content-type": "application/x-www-form-urlencoded"}
data = urllib.urlencode(data)
req = urllib2.Request(url, data, headers)
resp = urllib2.urlopen(req).read()
parsed = json.loads(resp)
access_token = parsed.get('access_token')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment