Skip to content

Remove special treatment of nonstandard "expires" parameter #506

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

Merged
merged 4 commits into from
Jun 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions oauthlib/oauth2/rfc6749/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,16 +362,13 @@ def parse_token_response(body, scope=None):
# https://github.com/oauthlib/oauthlib/issues/267

params = dict(urlparse.parse_qsl(body))
for key in ('expires_in', 'expires'):
if key in params: # cast a couple things to int
for key in ('expires_in',):
if key in params: # cast things to int
params[key] = int(params[key])

if 'scope' in params:
params['scope'] = scope_to_list(params['scope'])

if 'expires' in params:
params['expires_in'] = params.pop('expires')

if 'expires_in' in params:
params['expires_at'] = time.time() + int(params['expires_in'])

Expand Down
11 changes: 0 additions & 11 deletions tests/oauth2/rfc6749/test_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,6 @@ def setUp(self):
' "refresh_token": "tGzv3JOkF0XG5Qx2TlKWIA",'
' "example_parameter": "example_value" }')

json_expires = ('{ "access_token": "2YotnFZFEjr1zCsicMWpAA",'
' "token_type": "example",'
' "expires": 3600,'
' "refresh_token": "tGzv3JOkF0XG5Qx2TlKWIA",'
' "example_parameter": "example_value",'
' "scope":"abc def"}')

json_dict = {
'access_token': '2YotnFZFEjr1zCsicMWpAA',
'token_type': 'example',
Expand Down Expand Up @@ -264,7 +257,3 @@ def record_scope_change(sender, message, old, new):
finally:
signals.scope_changed.disconnect(record_scope_change)
del os.environ['OAUTHLIB_RELAX_TOKEN_SCOPE']

def test_token_response_with_expires(self):
"""Verify fallback for alternate spelling of expires_in. """
self.assertEqual(parse_token_response(self.json_expires), self.json_dict)