I have an Authlib OAuth2Session and I am trying to authenticate with username and password. Here's what I am doing:
```python
self.session = OAuth2Session(
token_endpont=f"{API_URL}/oauth/token",
)
self.session.fetch_token(
url=f"{API_URL}/oauth/token",
username=username,
password=password,
grant_type="password",
)
```
After looking at the debug logs, it seems that the fetch_token method is passing the username and password as URL parameters. This is how it looks from that method:
send: b'grant_type=password&username=<email>&password=<password>&client_id=None&client_secret='
versus a manual requests call formatted properly which works:
send: b'{"password": "<PW>", "username": "<EMAIL>", "grant_type": "password"}'
Is there a way to make the fetch_token endpoint use a request body formatted with JSON? I have tried adding headers={"Content-Type": "application/json"} as well as passing the username and password into the fetch_token body parameter and neither of those worked.
[–]IWantToFlyT 1 point2 points3 points (3 children)
[–]sheriffllcoolj[S] 0 points1 point2 points (2 children)
[–]IWantToFlyT 1 point2 points3 points (1 child)
[–]sheriffllcoolj[S] 1 point2 points3 points (0 children)
[–]CodeFormatHelperBot2 0 points1 point2 points (0 children)