A
A
Alexey2019-08-14 09:45:55
JSON Web Token
Alexey, 2019-08-14 09:45:55

How to update access token using JSON Web Token and Passport JWT?

I generate a token:

// jsonwebtoken package - creating token and answer on him
        var token = jwt.sign(payload, jwtOptions.secretOrKey, { expiresIn: '10m' });
        res.json({token: 'Bearer ' + token});

After 10 minutes, the user will be 'unauthorized'.
Questions:
How and where to get a refresh token?
How will the express route look like to receive a refresh token and generate a new access token?

PS Is it true that JWT is not used in production? How to correctly authorize a user by JWT in express?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
RidgeA, 2019-08-14
@azovl

How and where to get a refresh token?

Together with access-token
as an option:
получить refresh_token из тела запроса
если refresh_token в есть базе и он не просрочен 
  то
    сгенерировать новую пару acces_token и refresh_token
    сохранить refresh_token в базе данных
  иначе
    вернуть ошибку что refresh_token недействительный

No

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question