8000 Merge pull request #134 from craigcitro/revoke · akrherz/google-api-python-client@7504459 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7504459

Browse files
committed
Merge pull request googleapis#134 from craigcitro/revoke
Fall back to using an access_token for revocation.
2 parents d68049b + b574bc2 commit 7504459

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

oauth2client/client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -811,16 +811,16 @@ def _do_refresh_request(self, http_request):
811811
raise AccessTokenRefreshError(error_msg)
812812

813813
def _revoke(self, http_request):
814-
"""Revokes the refresh_token and deletes the store if available.
814+
"""Revokes this credential and deletes the stored copy (if it exists).
815815
816816
Args:
817817
http_request: callable, a callable that matches the method signature of
818818
httplib2.Http.request, used to make the revoke request.
819819
"""
820-
self._do_revoke(http_request, self.refresh_token)
820+
self._do_revoke(http_request, self.refresh_token or self.access_token)
821821

822822
def _do_revoke(self, http_request, token):
823-
"""Revokes the credentials and deletes the store if available.
823+
"""Revokes this credential and deletes the stored copy (if it exists).
824824
825825
Args:
826826
http_request: callable, a callable that matches the method signature of

tests/test_oauth2client.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,14 @@ def test_token_revoke_failure(self):
560560
self, '400', revoke_raise=True,
561561
valid_bool_value=False, token_attr='refresh_token')
562562

563+
def test_token_revoke_fallback(self):
564+
original_credentials = self.credentials.to_json()
565+
self.credentials.refresh_token = None
566+
_token_revoke_test_helper(
567+
self, '200', revoke_raise=False,
568+
valid_bool_value=True, token_attr='access_token')
569+
self.credentials = self.credentials.from_json(original_credentials)
570+
563571
def test_non_401_error_response(self):
564572
http = HttpMockSequence([
565573
({'status': '400'}, b''),

0 commit comments

Comments
 (0)
0