-
Notifications
You must be signed in to change notification settings - Fork 303
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._client #13
Conversation
Context: this will be used by oauth2.0-based credentials: Having the grants implemented in one place vastly simplifies the credential implementations and makes it far easy to cover in tests. |
error_data['error'], | ||
error_data.get('error_description')]) | ||
# If not details could be extracted, use the response data. | ||
except (KeyError, ValueError): |
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.
specified. | ||
""" | ||
expires_in = response_data.get('expires_in', None) | ||
if expires_in: |
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.
return _helpers.utcnow() + datetime.timedelta( | ||
seconds=expires_in) | ||
else: | ||
return 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.
""" | ||
body = urllib.parse.urlencode(body) | ||
headers = { | ||
'content-type': 'application/x-www-form-urlencoded', |
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.
response = request( | ||
method='POST', url=token_uri, headers=headers, body=body) | ||
|
||
response_body = response.data.decode('utf-8') |
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.
|
||
response_data = _token_endpoint_request(request, token_uri, body) | ||
|
||
access_token = response_data['access_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.
import json | ||
|
||
import mock | ||
import pytest |
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__handle_error_response(): | ||
response_data = json.dumps({ | ||
'error': 'help', | ||
'error_description': 'I\'m alive'}) |
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.
with pytest.raises(exceptions.RefreshError) as excinfo: | ||
_client._handle_error_response(response_data) | ||
|
||
assert excinfo.match(r'help: I\'m alive') |
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 _client._parse_expiry({}) is None | ||
|
||
|
||
def test__token_endpoint_request(): |
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 |
(branch name unrelated)