Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New token will not be fetched if grant_type='client_credentials' is passed for fetch_token() #660

Open
bryan-prime opened this issue Jul 16, 2024 · 0 comments
Assignees
Labels

Comments

@bryan-prime
Copy link

bryan-prime commented Jul 16, 2024

Describe the bug

If I pass client_credentials as the grant_type it will not automatically fetch the new token.

To Reproduce

My code where I pass the grant_type.

self.oauth2client = OAuth2Session(token_endpoint=f"{base_url}/auth/token")
self.oauth2client.fetch_token(grant_type="client_credentials",)

https://github.com/lepture/authlib/blob/master/authlib/oauth2/client.py#L199-L204

self.metadata is only set if None was passed for grant_type

https://github.com/lepture/authlib/blob/master/authlib/oauth2/client.py#L279-L284

self.metadata['grant_type'] will be None so it will not fetch the new token.

My workaround was passing nothing for fetch token because it luckily defaults to client_credentials if nothing was passed for the grant_type.

Expected behavior

A clear and concise description of what you expected to happen.

Environment:

  • OS: OSX
  • Python Version: 3.11
  • Authlib Version: 1.3.1

Additional context

Add any other context about the problem here.

@bryan-prime bryan-prime changed the title New token will not be fetched if grant_type is passed for fetch_token() New token will not be fetched if grant_type='client_credentials' is passed for fetch_token() Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants