-
Notifications
You must be signed in to change notification settings - Fork 311
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
@@ -370,6 +370,8 @@ | |||
'python': ('https://docs.python.org/3.5', None), | |||
'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.
|
||
# 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.
|
||
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.
@@ -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.