Login not working
pausanchezv opened this issue · 4 comments
Hello,
I have followed all the steps in your example but I can't make it work. I complains about me not having installed the AuthenticationMiddleware in fastapi, which is weird because you don't mention it in the docs. The error I am being given when I set a breakpoint to catch the request is:
'AuthenticationMiddleware must be installed to access request.user'
The line of code that crashes is:
user = await google_sso.verify_and_process(request)
Which is returning:
oauthlib.oauth2.rfc6749.errors.CustomOAuth2Error: (redirect_uri_mismatch) Bad Request
Is there anything I am missing? If so, could you add it to the docs? If not, can you help please?
Thanks
Stupid me I realized it only works under https since in production it works as expected. The solution is faking the ssl when in local!
@pausanchezv that's right, some services will require you to use https
. In case you want to test locally and you are sure you set up your redirect uri in your sso provider to point to http://localhost
(not https://localhost
), you can add this to your environment and should be able to use pure http
as well:
OAUTHLIB_INSECURE_TRANSPORT=1
Let me point you to StackOverflow's answer I initially used to make this work:
https://stackoverflow.com/a/27785830
Yeah Thanks! I just used mkcert to get a local ssl certificate and I now I use https anyways, which is also fine! Thanks for the extra alternative you suggested!