1

Not been able to generate token because of this error

if check_password_hash(user.password, auth.password):
        token = jwt.encode({'public_id':user.public_id,'exp':
        datetime.datetime.utcnow() + datetime.timedelta(minutes=30)},app.config['SECRET_KEY'])
        print(token)

        return jsonify({'token':token.decode("UTF-8")})
6
  • Check if user object is actuallly getting in, check if SECRET_KEY is defined. Also remove the print(token) before the return everything else looks good. Commented Jul 4, 2021 at 7:44
  • Which line is triggering the TypeError? Commented Jul 4, 2021 at 8:40
  • I don't know, After passing name and password in basic authentication. token=jwt is giving error Commented Jul 6, 2021 at 13:57
  • Yes @EddwinPaz SECRET_KEY is defined. After removing print(token) error is same. I cant find why it is asking for string value. Commented Jul 6, 2021 at 13:59
  • what library are you using for jwt? Commented Jul 6, 2021 at 14:15

1 Answer 1

3

You should add

JWT_SECRET_KEY="some_random_string" 

in settings.py file and it will run fine

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.