11

After searching the web, I found there are many posts and modules help parse bearer token, but I didn't found any help create one.

How should I properly generate a bearer token in node.js server?

1
  • 4
    Disregard the downvoter. There was nothing wrong with this question, thanks for asking it. Commented Aug 9, 2017 at 22:51

1 Answer 1

12

You can use jwt.io token. To generate a token check out jsonwebtoken module.

You can generate a token like this:

let token = jwt.sign({
  exp: Math.floor(Date.now() / 1000) + (60 * 60),
  data: 'foobar'
}, 'secret');

There are plenty other examples in the docs.

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.