jpadilla / pyjwt

JSON Web Token implementation in Python
https://pyjwt.readthedocs.io
MIT License
5k stars 675 forks source link

Add a timeout for PyJWKClient requests #875

Closed daviddavis closed 1 year ago

daviddavis commented 1 year ago

By default, the timeout for urlopen is socket._GLOBAL_DEFAULT_TIMEOUT which is None (meaning that the request never times out):

https://docs.python.org/3/library/socket.html#socket.getdefaulttimeout

This change sets the timeout to 30 but also adds a timeout variable users can set.

daviddavis commented 1 year ago

To test, simply run nc -l 8080 and then use this example but set the url to "http://localhost:8080".

auvipy commented 1 year ago

would you mind adding the regression test as well?