E_INVALID_JWT_REFRESH_TOKEN: Invalid refresh token

#1

Hi,

When I try to generate new refresh token I keep getting E_INVALID_JWT_REFRESH_TOKEN error.I want to create a new refresh token on every request and delete the old one.This method is provided in version 4.1 documentation but this doesn’t work.

Controller

const refreshToken = request.input("refreshToken");
const token = await auth.newRefreshToken().generateForRefreshToken(refreshToken);

JWT Config

jwt: {
    serializer: "lucid",
    model: "App/Models/User",
    scheme: "jwt",
    uid: "email",
    password: "password",
    options: {
      secret: Env.get("APP_KEY"),
      expiresIn: 60
    }
  }

[details=“Summary”]
This text will be hidden
[/details]Preformatted text

0 Likes

#2

Hey @varinder! :wave:

Have you verified that the return value of request.input("refreshToken") is the correct token?

Also, I’d be easier for us to help you if you create a repository to reproduce your issue.

0 Likes

#3

Hi Romain,

Thank you for replying.I have verified the return value it is correct.when I create a token using

await auth.generateForRefreshToken(refreshToken)

it creates a token from the refresh token and returns new token and same refresh token which is passed.

The issue is I want to create a new refresh token also so I use

await auth.newRefreshToken().generateForRefreshToken(refreshToken)

this gives this error:
InvalidRefreshToken: E_INVALID_JWT_REFRESH_TOKEN: Invalid refresh token

I want to create a new refresh token on each request and delete the older refresh token.

Thanks

0 Likes

#4

This is maybe related: https://github.com/adonisjs/adonis-auth/issues/129

0 Likes

#5

Hi,

I have checked that is a different issue.I want to create a new refresh token whenever I login a user using the refresh token.

0 Likes