diff options
author | José Padilla <jpadilla@webapplicate.com> | 2019-12-27 10:38:29 -0500 |
---|---|---|
committer | José Padilla <jpadilla@webapplicate.com> | 2020-04-06 09:32:04 -0400 |
commit | 1f4b8c6c3aed0d975232ce6e1b0f797d356a856b (patch) | |
tree | d233005e6f3cb1d5ab4eca0f173dcba0ad071765 | |
parent | 2275e41d8ed4acd1f5b0772c204583bc1ad541e3 (diff) | |
download | pyjwt-1f4b8c6c3aed0d975232ce6e1b0f797d356a856b.tar.gz |
Guard against optional dependency
-rw-r--r-- | jwt/jwks_client.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/jwt/jwks_client.py b/jwt/jwks_client.py index 887d574..e8c0751 100644 --- a/jwt/jwks_client.py +++ b/jwt/jwks_client.py @@ -1,12 +1,20 @@ -import requests - from .api_jwk import PyJWKSet from .api_jwt import decode as decode_token from .exceptions import PyJWKClientError +try: + import requests +except ImportError: + requests = None + class PyJWKClient: def __init__(self, uri): + if not requests: + raise PyJWKClientError( + "Missing dependencies for `PyJWKClient`. Run `pip install pyjwt[jwks-client]` to install dependencies." + ) + self.uri = uri def fetch_data(self): |