Skip to content

Commit

Permalink
Merge pull request #547 from looi/client_credentials_refresh
Browse files Browse the repository at this point in the history
Auto refresh token for detected client_credentials grant type
  • Loading branch information
lepture authored Sep 13, 2023
2 parents 1846d6a + 71f2521 commit 1807ba6
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions authlib/oauth2/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,10 @@ def fetch_token(self, url=None, body='', method='POST', headers=None,
if grant_type is None:
grant_type = self.metadata.get('grant_type')

if grant_type is None:
grant_type = _guess_grant_type(kwargs)
self.metadata['grant_type'] = grant_type

body = self._prepare_token_endpoint_body(body, grant_type, **kwargs)

if auth is None:
Expand Down Expand Up @@ -401,9 +405,6 @@ def _handle_token_hint(self, hook, url, token=None, token_type_hint=None,
url, body, auth=auth, headers=headers, **session_kwargs)

def _prepare_token_endpoint_body(self, body, grant_type, **kwargs):
if grant_type is None:
grant_type = _guess_grant_type(kwargs)

if grant_type == 'authorization_code':
if 'redirect_uri' not in kwargs:
kwargs['redirect_uri'] = self.redirect_uri
Expand Down

0 comments on commit 1807ba6

Please sign in to comment.