@@ -133,7 +133,7 @@ def _obtain_token( # The verb "obtain" is influenced by OAUTH2 RFC 6749
133133 "Token response is not in json format: %s" , resp .text )
134134 raise
135135
136- def obtain_token_with_refresh_token (self , refresh_token , scope = None , ** kwargs ):
136+ def obtain_token_by_refresh_token (self , refresh_token , scope = None , ** kwargs ):
137137 """Obtain an access token via a refresh token.
138138
139139 :param refresh_token: The refresh token issued to the client
@@ -278,7 +278,7 @@ def parse_auth_response(params, state=None):
278278 raise ValueError ('state mismatch' )
279279 return params
280280
281- def obtain_token_with_authorization_code (
281+ def obtain_token_by_authorization_code (
282282 self , code , redirect_uri = None , ** kwargs ):
283283 """Get a token via auhtorization code. a.k.a. Authorization Code Grant.
284284
@@ -299,18 +299,20 @@ def obtain_token_with_authorization_code(
299299 data ["client_id" ] = self .client_id
300300 return self ._obtain_token ("authorization_code" , data = data , ** kwargs )
301301
302- def obtain_token_with_username_password (
302+ def obtain_token_by_username_password (
303303 self , username , password , scope = None , ** kwargs ):
304304 """The Resource Owner Password Credentials Grant, used by legacy app."""
305305 data = kwargs .pop ("data" , {})
306306 data .update (username = username , password = password , scope = scope )
307307 return self ._obtain_token ("password" , data = data , ** kwargs )
308308
309- def obtain_token_with_client_credentials (self , scope = None , ** kwargs ):
310- """Get token by client credentials. a.k.a. Client Credentials Grant ,
311- used by Backend Applications.
309+ def obtain_token_for_client (self , scope = None , ** kwargs ):
310+ """Obtain token for this client (rather than for an end user) ,
311+ a.k.a. the Client Credentials Grant, used by Backend Applications.
312312
313- You may want to explicitly provide an optional client_secret parameter,
313+ We don't name it obtain_token_by_client_credentials(...) because those
314+ credentials are typically already provided in class constructor, not here.
315+ You can still explicitly provide an optional client_secret parameter,
314316 or you can provide such extra parameters as `default_body` during the
315317 class initialization.
316318 """
@@ -352,7 +354,7 @@ def _obtain_token(self, grant_type, params=None, data=None, *args, **kwargs):
352354 })
353355 return resp
354356
355- def obtain_token_with_refresh_token (self , token_item , scope = None ,
357+ def obtain_token_by_refresh_token (self , token_item , scope = None ,
356358 rt_getter = lambda token_item : token_item ["refresh_token" ],
357359 ** kwargs ):
358360 # type: (Union[str, dict], Union[str, list, set, tuple], Callable) -> dict
@@ -367,10 +369,10 @@ def obtain_token_with_refresh_token(self, token_item, scope=None,
367369 """
368370 if isinstance (token_item , str ):
369371 # Satisfy the L of SOLID, although we expect caller uses a dict
370- return super (Client , self ).obtain_token_with_refresh_token (
372+ return super (Client , self ).obtain_token_by_refresh_token (
371373 token_item , scope = scope , ** kwargs )
372374 if isinstance (token_item , dict ):
373- resp = super (Client , self ).obtain_token_with_refresh_token (
375+ resp = super (Client , self ).obtain_token_by_refresh_token (
374376 rt_getter (token_item ), scope = scope , ** kwargs )
375377 if resp .get ('error' ) == 'invalid_grant' :
376378 self .on_removing_rt (token_item ) # Discard old RT
@@ -379,7 +381,7 @@ def obtain_token_with_refresh_token(self, token_item, scope=None,
379381 return resp
380382 raise ValueError ("token_item should not be a type %s" % type (token_item ))
381383
382- def obtain_token_with_assertion (
384+ def obtain_token_by_assertion (
383385 self , assertion , grant_type = None , scope = None , ** kwargs ):
384386 # type: (str, Union[str, None], Union[str, list, set, tuple]) -> dict
385387 """This method implements Assertion Framework for OAuth2 (RFC 7521).
0 commit comments