Created
October 3, 2020 23:34
-
-
Save karmanyaahm/aa2a035e5a9e38d60b5fbf1507db2d0f to your computer and use it in GitHub Desktop.
Google OpenID API Python get User Info
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
##it took me hours to find what I wanted in between deprecated APIs and lacking documentation as of Oct 2020, hopefully this'll help someone | |
import requests | |
creds = google.oauth2.credentials.Credentials ###not real thing, replace with the credentials you got from the flow | |
url = 'https://openidconnect.googleapis.com/v1/userinfo' | |
head = { 'Authorization': 'Bearer '+creds.token} | |
response = requests.get(url, headers=head) | |
print(response.json()['sub']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment