@@ -1020,48 +1020,42 @@ def repository(self, owner, repository):
10201020 json = self ._json (self ._get (url ), 200 )
10211021 return Repository (json , self ) if json else None
10221022
1023- def _revoke_authorization (self , access_token = None ):
1024- """Helper method for revoking application authorization keys.
1025-
1026- :param str access_token: (optional), the access token to delete; if
1027- not provided, revoke all access tokens for this application
1028-
1029- """
1030- p = self ._session .params
1031- client_id = p .get ('client_id' )
1032- client_secret = p .get ('client_secret' )
1033- if client_id and client_secret :
1034- auth = (client_id , client_secret )
1035- url_parts = ['applications' , str (auth [0 ]), 'tokens' ]
1036- if access_token :
1037- url_parts .append (access_token )
1038- url = self ._build_url (* url_parts )
1039- return self ._delete (url , auth = auth , params = {
1040- 'client_id' : None , 'client_secret' : None
1041- })
1042- return False
1043-
10441023 @requires_app_credentials
10451024 def revoke_authorization (self , access_token ):
10461025 """Revoke specified authorization for an OAuth application.
10471026
1048- Revoke all authorization tokens created by your application.
1027+ Revoke all authorization tokens created by your application. This will
1028+ only work if you have already called ``set_client_id``.
10491029
10501030 :param str access_token: (required), the access_token to revoke
10511031 :returns: bool -- True if successful, False otherwise
10521032 """
1053- self ._revoke_authorization (access_token )
1033+ client_id , client_secret = self ._session .retrieve_client_credentials ()
1034+ url = self ._build_url ('applications' , str (client_id ), 'tokens' ,
1035+ access_token )
1036+ with self ._session .temporary_basic_auth (client_id , client_secret ):
1037+ response = self ._delete (url , params = {'client_id' : None ,
1038+ 'client_secret' : None })
1039+
1040+ return self ._boolean (response , 204 , 404 )
10541041
10551042 @requires_app_credentials
10561043 def revoke_authorizations (self ):
10571044 """Revoke all authorizations for an OAuth application.
10581045
1059- Revoke all authorization tokens created by your application.
1046+ Revoke all authorization tokens created by your application. This will
1047+ only work if you have already called ``set_client_id``.
10601048
10611049 :param str client_id: (required), the client_id of your application
10621050 :returns: bool -- True if successful, False otherwise
10631051 """
1064- self ._revoke_authorization ()
1052+ client_id , client_secret = self ._session .retrieve_client_credentials ()
1053+ url = self ._build_url ('applications' , str (client_id ), 'tokens' )
1054+ with self ._session .temporary_basic_auth (client_id , client_secret ):
1055+ response = self ._delete (url , params = {'client_id' : None ,
1056+ 'client_secret' : None })
1057+
1058+ return self ._boolean (response , 204 , 404 )
10651059
10661060 def search_code (self , query , sort = None , order = None , per_page = None ,
10671061 text_match = False , number = - 1 , etag = None ):
0 commit comments