DEV Community

Discussion on: What is the usual flow in authenticating a Client Application with a Token based REST API?

jjjjcccjjf profile image
endan Author

But isn't storing Refresh Tokens on localStorage a bad practice because it can be tampered?

Thread Thread
skyrpex profile image
Cristian Pallarés

IMO you should NOT store those credentials in local storage. Refresh tokens are supposed to only be seen by servers, aren't they?

Take a look at Laravel Passport approach: uses traditional cookies to store an access token and a CSRF token.

Thread Thread
lims profile image
Lucas

The refresh token by itself does not provide any information about the user, (the access token yes), so I don't really see the problem in storing it in local storage. However, I understand your concerns.

Thread Thread
skyrpex profile image
Cristian Pallarés

The issue is about letting the JS have access to any kind of credentials. Traditional session cookies are usually http only for that matter. The same applies to access tokens or refresh tokens.

It's just about avoiding attack vectors.