Skip to content

Commit abaf927

Browse files
committed
Add GitHub#revoke_authorizations
1 parent 2145262 commit abaf927

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

github3/github.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,6 +1022,17 @@ def repository(self, owner, repository):
10221022
json = self._json(self._get(url), 200)
10231023
return Repository(json, self) if json else None
10241024

1025+
def revoke_authorizations(self, client_id):
1026+
"""Revoke all authorizations for an OAuth application.
1027+
1028+
Revoke all authorization tokens created by your application.
1029+
1030+
:param str client_id: (required), the client_id of your application
1031+
:returns: bool -- True if successful, False otherwise
1032+
"""
1033+
url = self._build_url('applications', str(client_id), 'tokens')
1034+
return self._boolean(self._delete(url), 204, 404)
1035+
10251036
def search_code(self, query, sort=None, order=None, per_page=None,
10261037
text_match=False, number=-1, etag=None):
10271038
"""Find code via the code search API.

tests/unit/test_github.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,9 @@ def test_two_factor_login(self):
1414
def test_can_login_without_two_factor_callback(self):
1515
self.instance.login('username', 'password')
1616
self.instance.login(token='token')
17+
18+
def test_revoke_authorizations(self):
19+
self.instance.revoke_authorizations('client_id')
20+
self.session.delete.assert_called_once_with(
21+
'https://api.github.com/applications/client_id/tokens'
22+
)

0 commit comments

Comments
 (0)