@@ -1019,29 +1019,46 @@ def repository(self, owner, repository):
10191019 json = self ._json (self ._get (url ), 200 )
10201020 return Repository (json , self ) if json else None
10211021
1022- def revoke_authorization (self , client_id , access_token ):
1022+ def _revoke_authorization (self , access_token = None ):
1023+ """Helper method for revoking application authorization keys.
1024+
1025+ :param str access_token: (optional), the access token to delete; if
1026+ not provided, revoke all access tokens for this application
1027+
1028+ """
1029+ p = self ._session .params
1030+ client_id = p .get ('client_id' )
1031+ client_secret = p .get ('client_secret' )
1032+ if client_id and client_secret :
1033+ auth = (client_id , client_secret )
1034+ url_parts = ['applications' , str (auth [0 ]), 'tokens' ]
1035+ if access_token :
1036+ url_parts .append (access_token )
1037+ url = self ._build_url (* url_parts )
1038+ return self ._delete (url , auth = auth , params = {
1039+ 'client_id' : None , 'client_secret' : None
1040+ })
1041+ return False
1042+
1043+ def revoke_authorization (self , access_token ):
10231044 """Revoke specified authorization for an OAuth application.
10241045
10251046 Revoke all authorization tokens created by your application.
10261047
1027- :param str client_id: (required), the client_id of your application
1028- :param str acess_token: (required), the access_token to revoke
1048+ :param str access_token: (required), the access_token to revoke
10291049 :returns: bool -- True if successful, False otherwise
10301050 """
1031- url = self ._build_url ('applications' , str (client_id ), 'tokens' ,
1032- str (access_token ))
1033- return self ._boolean (self ._delete (url ), 204 , 404 )
1051+ self ._revoke_authorization (access_token )
10341052
1035- def revoke_authorizations (self , client_id ):
1053+ def revoke_authorizations (self ):
10361054 """Revoke all authorizations for an OAuth application.
10371055
10381056 Revoke all authorization tokens created by your application.
10391057
10401058 :param str client_id: (required), the client_id of your application
10411059 :returns: bool -- True if successful, False otherwise
10421060 """
1043- url = self ._build_url ('applications' , str (client_id ), 'tokens' )
1044- return self ._boolean (self ._delete (url ), 204 , 404 )
1061+ self ._revoke_authorization ()
10451062
10461063 def search_code (self , query , sort = None , order = None , per_page = None ,
10471064 text_match = False , number = - 1 , etag = None ):
0 commit comments