-
Notifications
You must be signed in to change notification settings - Fork 14
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Bug description
I'm trying to implement my own oauth implementation.
Trying this with logto returns '(invalid_request) client authentication must only be provided using one mechanism'
fastapi-oauth2/src/fastapi_oauth2/core.py
Lines 111 to 124 in 33b42dc
oauth2_query_params = dict( | |
redirect_url=redirect_uri, | |
client_secret=self.client_secret, | |
authorization_response=authorization_response, | |
) | |
oauth2_query_params.update(request.query_params) | |
token_url, headers, content = self._oauth_client.prepare_token_request( | |
self._token_endpoint, | |
**oauth2_query_params, | |
) | |
headers.update({"Accept": "application/json"}) | |
auth = httpx.BasicAuth(self.client_id, self.client_secret) |
Here the client_secret
is set both for the Authorization header and to the request body.
According to this post and other posts only one is supposed to be there. header seems to be preferred based on my limited knowledge.
Simply removing line 113 client_secret=self.client_secret,
solves my problem
Reproduction URL
No response
Reproduction steps
- Add middleware
class MyOAuth2(BaseOAuth2):
name = "my"
AUTHORIZATION_URL = os.getenv("AUTHORIZE_URL")
ACCESS_TOKEN_URL = os.getenv("TOKEN_URL")
REFRESH_TOKEN_URL = os.getenv("REFRESH_TOKEN_URL") or ""
app.add_middleware(
OAuth2Middleware,
config=OAuth2Config(
allow_http=True,
clients=[
OAuth2Client(
backend=MyOAuth2,
client_id=os.getenv("CLIENT_ID") or "",
client_secret=os.getenv("CLIENT_SECRET") or "",
# redirect_uri=os.getenv("REDIRECT_URI"),
scope=scopes.split(" "),
)
],
),
callback=on_auth_success,
on_error=on_auth_error,
)
- Navigate to
/oauth2/my/authorize
Screenshots
No response
Logs
No response
Browsers
Firefox, Chrome
OS
Windows, Linux
ArtyomVancyan
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
Type
Projects
Status
Done