Skip to content
This repository has been archived by the owner on Nov 5, 2019. It is now read-only.

Commit

Permalink
Merge pull request #134 from craigcitro/revoke
Browse files Browse the repository at this point in the history
Fall back to using an access_token for revocation.
  • Loading branch information
craigcitro committed Mar 17, 2015
2 parents d68049b + b574bc2 commit 7504459
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
6 changes: 3 additions & 3 deletions oauth2client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -811,16 +811,16 @@ def _do_refresh_request(self, http_request):
raise AccessTokenRefreshError(error_msg)

def _revoke(self, http_request):
"""Revokes the refresh_token and deletes the store if available.
"""Revokes this credential and deletes the stored copy (if it exists).
Args:
http_request: callable, a callable that matches the method signature of
httplib2.Http.request, used to make the revoke request.
"""
self._do_revoke(http_request, self.refresh_token)
self._do_revoke(http_request, self.refresh_token or self.access_token)

def _do_revoke(self, http_request, token):
"""Revokes the credentials and deletes the store if available.
"""Revokes this credential and deletes the stored copy (if it exists).
Args:
http_request: callable, a callable that matches the method signature of
Expand Down
8 changes: 8 additions & 0 deletions tests/test_oauth2client.py
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,14 @@ def test_token_revoke_failure(self):
self, '400', revoke_raise=True,
valid_bool_value=False, token_attr='refresh_token')

def test_token_revoke_fallback(self):
original_credentials = self.credentials.to_json()
self.credentials.refresh_token = None
_token_revoke_test_helper(
self, '200', revoke_raise=False,
valid_bool_value=True, token_attr='access_token')
self.credentials = self.credentials.from_json(original_credentials)

def test_non_401_error_response(self):
http = HttpMockSequence([
({'status': '400'}, b''),
Expand Down

0 comments on commit 7504459

Please sign in to comment.