Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 25fba64
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions docs/oauth.md
Expand Up @@ -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')
```

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 25fba64

Please sign in to comment.