-
Notifications
You must be signed in to change notification settings - Fork 215
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
Report helpful error message for missing "jwt" dependency #526
Comments
@supermitch Thank you for the feedback! We will take a look at this. |
@supermitch We are currently prioritizing bugs over enhancements in all our SDKs, so it may take a while for us to get to some of these. If are interested in submitting PRs for the enhancements, we would love to take a look! |
I'm having a similar issue when using the library in AWS Lambda, even though I installed the JWT extra (I downloaded the ZIP from Lambda and run it locally to double check):
...
├── boxsdk
│ ├── auth
│ │ ├── cooperatively_managed_oauth2.py
│ │ ├── developer_token_auth.py
│ │ ├── __init__.py
│ │ ├── jwt_auth.py
... My suspicion is that there's actually a different
# coding: utf-8
from __future__ import unicode_literals
from .cooperatively_managed_oauth2 import CooperativelyManagedOAuth2
from .developer_token_auth import DeveloperTokenAuth
try:
from .jwt_auth import JWTAuth
except ImportError:
JWTAuth = None # If extras[jwt] are not installed, JWTAuth won't be available. Update: I was able to log the error and my suspicion was confirmed: Traceback (most recent call last):
--
File "/var/task/boxsdk/auth/__init__.py", line 8, in <module>
from .jwt_auth import JWTAuth
File "/var/task/boxsdk/auth/jwt_auth.py", line 12, in <module>
from cryptography.hazmat.primitives import serialization
File "/var/task/cryptography/hazmat/primitives/serialization/__init__.py", line 15, in <module>
from cryptography.hazmat.primitives.serialization.base import (
File "/var/task/cryptography/hazmat/primitives/serialization/base.py", line 11, in <module>
from cryptography.hazmat.primitives.asymmetric.types import (
File "/var/task/cryptography/hazmat/primitives/asymmetric/types.py", line 7, in <module>
from cryptography.hazmat.primitives.asymmetric import (
File "/var/task/cryptography/hazmat/primitives/asymmetric/dsa.py", line 12, in <module>
from cryptography.hazmat.primitives.asymmetric import (
File "/var/task/cryptography/hazmat/primitives/asymmetric/utils.py", line 6, in <module>
from cryptography.hazmat.bindings._rust import asn1
ImportError: /lib64/libc.so.6: version `GLIBC_2.18' not found (required by /var/task/cryptography/hazmat/bindings/_rust.abi3.so) Would be nice to log these errors instead of swallowing them: import logging
...
try:
from .jwt_auth import JWTAuth
except ImportError:
logging.exception("An import error occurred") # Could be a warning as well
JWTAuth = None # If extras[jwt] are not installed, JWTAuth won't be available.
... It could also capture the error and ignore it if the cause is that the JWTAuth class is actually not found, while raising the error otherwise. I'm not entirely sure if it would raise an error unnecessarily in scenarios in which the user doesn't care about one of the extra modules. |
I've just been hit with the same issue as @federicojasson - issue with Interestingly, the original error does get surfaced correctly when I import directly:
rather than
|
Is your feature request related to a problem? Please describe.
As is known from closed issue (#387) if you don't
pip install "boxsdk[jwt]"
, and use the JWT authorization, you get a somewhat confusing message:Describe the solution you'd like
Return an error message instead that at least suggests "Did you try pip install boxsdk[jwt]?" when JWTAuth isn't going to work.
Additional context
Using sdk version
boxsdk 2.9.0
The text was updated successfully, but these errors were encountered: