I have some questions (more so confusion) about the use and or the reason behind refresh tokens when I'm using jsonwebtokens.
Firstly, why is it even needed? I fully understand the whole thing about short lived access tokens and long lived refresh tokens that are used to acquire new access tokens, but then I feel like that leaves the refresh token just as vulnerable and maybe more then normal access tokens
Secondly I hear people saying stuff about how the Resource server cares about the access token and the Authorization server cares about the refresh token. but I have 1 server just an API that I'm using jwt's to authorize and authenticate with
also yes, I do understand that its better experience for user because they can stay logged in for longer etc, but the question still rises why not just make the access token last a long time?
My question boils down to, why exactly are they needed / used and what makes them more secure then just using access tokens?
A long-lived token is needed if users shall be kept logged in to your service, for example via a mobile app, without having to repeat their consent over and over again. On the other hand, users must be able to revoke their consent (for example, after losing their mobile phone) or reduce its scope (for example, if the authorized app shall no longer be able to write to their service account, only read from it).
This means that before accepting a request, the server must not only validate the token but also verify that the user has not revoked it. For better performance, the two tasks are distributed between the resource server and the authorization server.
Even if your server plays both roles of authorization and resource server, it may make sense to distribute the tasks in the same way.