Skip to content
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

ModuleNotFoundError: No module named 'jose' #99

Closed
denizdogan opened this issue Jan 5, 2022 · 1 comment · Fixed by #100
Closed

ModuleNotFoundError: No module named 'jose' #99

denizdogan opened this issue Jan 5, 2022 · 1 comment · Fixed by #100

Comments

@denizdogan
Copy link
Contributor

  1. It seems that jose is not installed as a dependency
  2. It seems that jose is the wrong dependency (py2 only)
  3. It seems that python-jose is the right one (py3 support)

Installation:

$ poetry add drf-social-oauth2
Using version ^1.1.4 for drf-social-oauth2

Updating dependencies
Resolving dependencies... (0.8s)

Writing lock file

Package operations: 5 installs, 0 updates, 0 removals

  • Installing wrapt (1.13.3)
  • Installing deprecated (1.2.13)
  • Installing jwcrypto (1.0)
  • Installing django-oauth-toolkit (1.6.1)
  • Installing drf-social-oauth2 (1.1.4)

In settings:

ACTIVATE_JWT = True

Make request to /social/convert-token/:

{
    "grant_type": "convert_token",
    "client_id": "...",
    "client_secret": "...",
    "backend": "facebook",
    "token": "..."
}

Error:

  File ".../lib/python3.9/site-packages/oauthlib/oauth2/rfc6749/grant_types/refresh_token.py", line 62, in create_token_response
    token = token_handler.create_token(request,
  File ".../lib/python3.9/site-packages/oauthlib/oauth2/rfc6749/tokens.py", line 315, in create_token
    'access_token': self.token_generator(request),
  File ".../lib/python3.9/site-packages/drf_social_oauth2/__init__.py", line 23, in generate_token
    from jose import jwt
ModuleNotFoundError: No module named 'jose'

Installing jose explicitly:

$ poetry add jose
Using version ^1.0.0 for jose

Updating dependencies
Resolving dependencies... (5.6s)

Writing lock file

Package operations: 2 installs, 0 updates, 0 removals

  • Installing pycrypto (2.6.1)
  • Installing jose (1.0.0)

New error:

  File ".../lib/python3.9/site-packages/oauthlib/oauth2/rfc6749/tokens.py", line 315, in create_token
    'access_token': self.token_generator(request),
  File ".../lib/python3.9/site-packages/drf_social_oauth2/__init__.py", line 23, in generate_token
    from jose import jwt
  File ".../lib/python3.9/site-packages/jose.py", line 546
    print decrypt(deserialize_compact(jwt), {'k':key},
          ^
SyntaxError: invalid syntax

After investigations, I found python-jose:

$ poetry remove jose && poetry add python-jose
Updating dependencies
Resolving dependencies... (0.5s)

Writing lock file

Package operations: 0 installs, 0 updates, 2 removals

  • Removing jose (1.0.0)
  • Removing pycrypto (2.6.1)
Using version ^3.3.0 for python-jose

Updating dependencies
Resolving dependencies... (2.0s)

Writing lock file

Package operations: 4 installs, 0 updates, 0 removals

  • Installing pyasn1 (0.4.8)
  • Installing ecdsa (0.17.0)
  • Installing rsa (4.8)
  • Installing python-jose (3.3.0)

Now it works as expected.

@wagnerdelima
Copy link
Owner

wagnerdelima commented Jan 5, 2022

Hi @denizdogan,

Thank you for your issue. You are completely right. I forgot to add the python-jose (not jose) to the setup.py file. Would you be kind and open a pull request with the changes?

Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants