Add google.oauth2.flow - utility for doing OAuth 2.0 Authorization Flow#100
Add google.oauth2.flow - utility for doing OAuth 2.0 Authorization Flow#100
Conversation
| @@ -1,3 +1,7 @@ | |||
| div.document { | |||
| width: 1040px; | |||
| } | |||
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| 'urllib3': ('https://urllib3.readthedocs.io/en/stable', None), | ||
| 'requests': ('http://docs.python-requests.org/en/stable', None), | ||
| 'requests-oauthlib': ( | ||
| 'http://requests-oauthlib.readthedocs.io/en/stable', None), |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| flow = flow.Flow.from_client_secrets_file( | ||
| 'path/to/client_secrets.json', | ||
| scopes=['profile', 'email'], | ||
| redirect_uri='urn:ietf:wg:oauth:2.0:oob') |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
google/oauth2/flow.py
Outdated
|
|
||
| # Create the flow using the client secrets file from the Google API | ||
| # Console. | ||
| flow = flow.Flow.from_client_secrets_file( |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| # Tell the user to go to the authorization URL. | ||
| auth_url, _ = flow.authorization_url(prompt='consent') | ||
|
|
||
| print('Please go to this URL: {}'.format(auth_url)) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
google/oauth2/flow.py
Outdated
|
|
||
| Returns: | ||
| Mapping[str, str]: The obtained tokens. Typically, you will not use | ||
| return value and use :meth:`credentials`. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
tests/oauth2/test_flow.py
Outdated
| @@ -0,0 +1,134 @@ | |||
| # Copyright 2014 Google Inc. | |||
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
|
||
| from google.oauth2 import flow | ||
|
|
||
| DATA_DIR = os.path.join(os.path.dirname(__file__), '..', 'data') |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| assert instance.oauth2session.scope == mock.sentinel.scopes | ||
|
|
||
|
|
||
| @pytest.fixture |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
|
||
| import json | ||
|
|
||
| import requests_oauthlib |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
d'oh, fixed. |
Resolves #74.