Skip to content
Permalink
Browse files
docs: Update oauth docs to include snippet to get email address of au…
…thenticated user (#1088)

Fixes #1071  🦕

Note: I changed `scopes=['profile', 'email'],` to `scopes=['openid', 'https://www.googleapis.com/auth/userinfo.email', 'https://www.googleapis.com/auth/userinfo.profile'],` in the examples because I received a warning that the scope has changed.

> `Warning: Scope has changed from "email profile" to "https://www.googleapis.com/auth/userinfo.email openid https://www.googleapis.com/auth/userinfo.profile".`.
  • Loading branch information
parthea committed Nov 13, 2020
1 parent 260cea7 commit 25fba648ea647b62f2a6edc54ae927c1ed381b45
Showing with 8 additions and 2 deletions.
  1. +8 −2 docs/oauth.md
@@ -58,7 +58,7 @@ from google_auth_oauthlib.flow import Flow
...
flow = Flow.from_client_secrets_file(
'path/to/client_secrets.json',
scopes=['profile', 'email'],
scopes=['openid', 'https://www.googleapis.com/auth/userinfo.email', 'https://www.googleapis.com/auth/userinfo.profile'],
redirect_uri='urn:ietf:wg:oauth:2.0:oob')
```

@@ -125,12 +125,18 @@ from googleapiclient.discovery import build
flow = InstalledAppFlow.from_client_secrets_file(
'client_secrets.json',
scopes=['profile', 'email'])
scopes=['openid', 'https://www.googleapis.com/auth/userinfo.email', 'https://www.googleapis.com/auth/userinfo.profile'])
flow.run_local_server()
credentials = flow.credentials
service = build('calendar', 'v3', credentials=credentials)
# Optionally, view the email address of the authenticated user.
user_info_service = build('oauth2', 'v2', credentials=credentials)
user_info = user_info_service.userinfo().get().execute()
print(user_info['email'])
```

## Storage

0 comments on commit 25fba64

Please sign in to comment.