@@ -1019,29 +1019,46 @@ def repository(self, owner, repository):
1019
1019
json = self ._json (self ._get (url ), 200 )
1020
1020
return Repository (json , self ) if json else None
1021
1021
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 ):
1023
1044
"""Revoke specified authorization for an OAuth application.
1024
1045
1025
1046
Revoke all authorization tokens created by your application.
1026
1047
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
1029
1049
:returns: bool -- True if successful, False otherwise
1030
1050
"""
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 )
1034
1052
1035
- def revoke_authorizations (self , client_id ):
1053
+ def revoke_authorizations (self ):
1036
1054
"""Revoke all authorizations for an OAuth application.
1037
1055
1038
1056
Revoke all authorization tokens created by your application.
1039
1057
1040
1058
:param str client_id: (required), the client_id of your application
1041
1059
:returns: bool -- True if successful, False otherwise
1042
1060
"""
1043
- url = self ._build_url ('applications' , str (client_id ), 'tokens' )
1044
- return self ._boolean (self ._delete (url ), 204 , 404 )
<
8000
/code>
1061
+ self ._revoke_authorization ()
1045
1062
1046
1063
def search_code (self , query , sort = None , order = None , per_page = None ,
1047
1064
text_match = False , number = - 1 , etag = None ):
0 commit comments