15

I was trying to use jose library for authentication for one of my flask apps. using the import statement as follows

from jose import jwt

But it throws following An error,

Traceback (most recent call last):
   File "F:/XXX_XXX/xxxx-services-web/src/auth.py", line 6, in <module>
      from jose import jwt
   File "F:\Users\XXXX_XXXXX\AppData\Local\Programs\Python\Python37\lib\site-packages\jose.py", line 546
      print decrypt(deserialize_compact(jwt), {'k':key},
            ^
SyntaxError: invalid syntax

Is this library outdated?

Gihan Gamage
  • 2,944
  • 19
  • 27
  • 1
    seems like it's written for python 2 - you should search for python3 compatible alternatives or maybe try using [2to3 library](https://docs.python.org/3/library/2to3.html) to automatically migrate the library's source. – Tibebes. M Dec 02 '20 at 06:02

2 Answers2

28

installing python-jose instead of jose fixed my problem. https://pypi.org/project/python-jose/

Gihan Gamage
  • 2,944
  • 19
  • 27
4

One solution is to install python-jose instead of installing jose.

Apart from that you can use import python_jwt as jwt instead of from jose import jwt and install the package via pip install python-jwt

Amir nazary
  • 384
  • 1
  • 7