3

This is the basic code for jwt, but it is giving me an error.

import jwt
en  = jwt.encode({'some': 'payload'}, 'secret', algorithm='HS256')
print(en)

ERROR

Traceback (most recent call last):
  File "C:/Users/anurag.agrawal/Desktop/HackerRank/jwt/jjwwtt.py", line 3, in <module>
    en  = jwt.encode({'some': 'payload'}, 'secret', algorithm='HS256')
AttributeError: module 'jwt' has no attribute 'encode'
adamkgray
  • 1,717
  • 1
  • 10
  • 26

1 Answers1

2

On going through various articles over the internet, finally got the solution to this problem, the library imported is to be pyjwt, as below:


from jwt import PyJWT

en = PyJWT.encode({'some' : 'payload'}, key= 'secret' , algorithm= 'RS256') print(en)


There are a few errors I am getting post this, but for now, the problem of library is resolved.