frankie567 / httpx-oauth

Async OAuth client using HTTPX
https://frankie567.github.io/httpx-oauth/
MIT License
136 stars 45 forks source link

Timeout #272

Closed trazola closed 2 years ago

trazola commented 2 years ago

Hi, I get a "timeout" error when using the Oauth2 client for Facebook. Is it possible to set the timeout parameter?

frankie567 commented 2 years ago

Hi @trazola!

Could you give more details about the timeout you are getting? HTTPX has several kinds of timeout exceptions, so it would be worth to know which. Ideally, provide the stacktrace.

trazola commented 2 years ago

Hi, Below is a screenshot Screenshot from 2022-05-24 19-08-19

This problem occurs when using the fastapi-users library.

frankie567 commented 2 years ago

Could you confirm that you have access to the Facebook endpoint from your machine. You can try this cURL command for example:

curl -XPOST "https://graph.facebook.com/v5.0/oauth/access_token"

You should get a response like this:

{"error":{"message":"Missing redirect_uri parameter.","type":"OAuthException","code":191,"fbtrace_id":"APpAu3dZSPj8TxtKFOoSHzu"}}

Could you also try this and share the result:

curl -o /dev/null -s -w 'Establish Connection: %{time_connect}s\nTTFB: %{time_starttransfer}s\nTotal: %{time_total}s\n'  "https://graph.facebook.com/v5.0/oauth/access_token"

It should give you the timings required to get the response:

Establish Connection: 0.028551s
TTFB: 0.142856s
Total: 0.143010s
trazola commented 2 years ago

I attach screenshots :) Screenshot from 2022-05-25 22-50-38

Screenshot from 2022-05-25 22-51-34

trazola commented 2 years ago

The solution that helped me in another project where I was using HTTPX was to set the timeout value to a higher value. httpx.AsyncClient(timeout=30.0)

frankie567 commented 2 years ago

I see, your connection time is surprisingly high, and HTTPX has a default timeout of 5 seconds. Are you behind a VPN or something?

I'll think about a way to tune HTTPX settings directly.

frankie567 commented 2 years ago

I've released a new version v0.7.0, with the ability to customize the HTTPX client settings. You can see how in the documentation: https://frankie567.github.io/httpx-oauth/oauth2/#customize-httpx-client

trazola commented 2 years ago

Thank you for your help :).