-
Notifications
You must be signed in to change notification settings - Fork 309
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 oauth2 credentials #24
Conversation
optional `refresh token`_. | ||
|
||
Obtaining the initial access and refresh token is outside of the scope of this | ||
module. Consult `rfc6749 section 4.1` for complete details on the Authorization |
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 _client | ||
|
||
|
||
class Credentials(credentials.Scoped, credentials.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.
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.
def __init__(self, token, refresh_token=None, token_uri=None, | ||
client_id=None, client_secret=None, scopes=None): | ||
""" | ||
Args: |
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.
client_secret(str): The OAuth 2.0 client secret. Must be specified | ||
for refresh, can be left as None if the token can not be | ||
refreshed. | ||
scopes (Union[str, Sequence]): The scopes that were originally used |
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.
can not request additional scopes after authorization. | ||
""" | ||
super(Credentials, self).__init__() | ||
self.token = token |
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.
|
||
@_helpers.copy_docstring(credentials.Credentials) | ||
def refresh(self, request): | ||
access_token, refresh_token, expiry, _ = _client.refresh_grant( |
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.
from google.oauth2 import credentials | ||
|
||
|
||
class TestCredentials: |
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.
|
||
|
||
class TestCredentials: | ||
token_uri = 'https://example.com/oauth2/token' |
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.
self.credentials = credentials.Credentials( | ||
token=None, refresh_token='refresh_token', | ||
token_uri=self.token_uri, client_id='client_id', | ||
client_secret='client_secret') |
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.
|
||
def test_create_scoped(self): | ||
with pytest.raises(NotImplementedError): | ||
assert credentials == self.credentials.with_scopes('email') |
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.
LGTM, be sure to file the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dhermes LGTY?
def __init__(self, token, refresh_token=None, token_uri=None, | ||
client_id=None, client_secret=None, scopes=None): | ||
""" | ||
Args: |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
from google.oauth2 import credentials | ||
|
||
|
||
class TestCredentials: |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Oh I see you already said so, merging. |
No description provided.