-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Working with flask-oidc #660
Comments
Looks like that library is specifically using Google's OAuth2 flow which uses client id and secret in the post body instead of in the header which is, according to spec, not the best approach: https://tools.ietf.org/html/rfc6749#section-2.3.1
You would have to make changes to the library and include the client id and secret in the authorization header using basic authorization. |
It's actually funny that google does that, Golang has actually an extra variable for that: https://github.com/golang/oauth2/blob/f95fa95eaa936d9d87489b15d1d18b97c1ba9c28/internal/token.go#L92 |
Yeah... that was my thoughts too. The trouble is that I'm looking to use flask-oidc, which in turn uses google's oauth2client (which by the way, is deprecated!). Is there a setting in Hydra that would enable reading the code from the post body (since it's discouraged in the spec, but not forbidden)? |
Christ the google library is confused! The ctor for OAuth2WebServerFlow has the option:
but factory methods like flow_from_clientsecrets have no such options. |
The google library is encoding parameters into the body like so:
Could you please advise which of these is expected in the authorisation header? What would the authorisation header string look like? |
See https://en.wikipedia.org/wiki/Basic_access_authentication - the client id is the username and the client secret is the password |
No, unfortunately not |
Thanks... I was asking about what to put in the header as there seems to be support for both basic auth and bearer tokens. With basic, the code would go in the body then? |
yes, only the client id and secret are incorrect, everything else stays the same |
Right... so I'm monkey patching flask-oidc, and I've got it to include the header:
Inspecting in wireshark shows https://imgur.com/a/YfEAk . However, the request still fails, and hydra logs show:
Do you have any pointers as to what I'm missing? |
Try setting |
I'm guessing that's wireshark formatting. I'm trying the log level thing. |
Nope... it's not wireshark.... it's in the string... debugging. |
Right... the issue was with how python encoding works. I needed to change the code to:
and it worked like a charm. Thanks for your continued help on this. I'll submit a PR to flask-oidc. |
Nice, congratulations! :) |
I'm trying to use flask-oidc with Hydra. I've got it to the point where the user is redirected back to .../oidc_callback on the client website, which then attempts to exchange the "code" for tokens. This results in the step2_exchange of google's oauth2client to send a POST to hydra/oauth2/token
https://github.com/google/oauth2client/blob/3071457064f3705bab1b041bd624a10d5a2d2619/oauth2client/client.py#L1992
This results in the following error in Hydra:
I was wondering if there's a way around this problem.
The text was updated successfully, but these errors were encountered: