nuxt-community / auth-module

Zero-boilerplate authentication support for Nuxt 2
https://auth.nuxtjs.org
MIT License
1.93k stars 924 forks source link

A request to refresh the token is not sent in nuxt auth #1773

Open AmirmohammadBeheshti opened 2 years ago

AmirmohammadBeheshti commented 2 years ago

I want to implement the refresh token with nuxt-auth .

I read several articles in this field and coded, but I did not get the desired result and I am facing three basic problems.

1 - When I specify the max age for the access token, it does not expire at the specified time

2-The next problem I am facing is that when the access token expires, the refresh token request is not sent automatically.

3- And the next problem I have is that I want to pass the refresh token in the request header, but I can't

auth: {
    strategies: {
      local: {
        scheme: "refresh",
        token: {
          property: "data.accessToken",
          maxAge: false,
          global: true,
          // type: 'Bearer'
        },
        refreshToken: {
          property: "data.refreshToken",
          data: "refresh_token",
          maxAge: false,
        },
        user: {
          property: "data",
          autoFetch: true,
        },
        endpoints: {
          login: { url: "/api/v1/auth/login", method: "post" },
          refresh: { url: "/api/v1/auth/refresh", method: "post" },
          user: { url: "/api/v1/profile", method: "get" },
          logout: { url: "/api/v1/auth/logout", method: "post" },
        },
        // autoLogout: false
      },
    },
  },

this is my auth strategy