nuxt-community / auth-module

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

Google Auth: ExpiredAuthSessionError: Both token and refresh token have expired. Your request was aborted. #1679

Closed ervan23 closed 2 years ago

ervan23 commented 2 years ago

Version

"@nuxtjs/auth-next": "5.0.0-1607693598.34d83ea" "nuxt": "^2.15.2"

Nuxt configuration

mode:

Nuxt configuration

  auth: {
    plugins: [{ src: "~/plugins/axios.js", ssr: true }],
    strategies: {
      local: {
        token: {
          property: "data.token",
          required: true,
          type: "",
          maxAge: 18000,
        },
        user: {
          property: "data",
          autoFetch: true,
        },
        endpoints: {
          login: { url: "/api/main", method: "post" },
          logout: { url: "/api/profiles/logout", method: "get" },
          user: { url: "/api/profile", method: "get" },
        },
      },
      google: {
        responseType: "code",
        clientId:"<google client ID>",
        codeChallengeMethod: "",
        grantType: "authorization_code",
        redirectUri: `${baseUrl}/verify-auth`,
      },
    },
    redirect: {
      login: "/login",
      logout: "/login",
      callback: "/login",
      home: "/",
    },
  },

Reproduction

ExpiredAuthSessionError: Both token and refresh token have expired. Your request was aborted. at a5d2e4e.js:1:4374

Steps to reproduce

After selecting a google account, then redirected to /verify-auth, then the error occurred. After /verify-auth it should go in.

Intevel commented 2 years ago

Hey, are you sure that the refresh token is right or has not expired?

ervan23 commented 2 years ago

@Intevel Yeah sure, but I already fix it. my API using Authorization header without Bearer. But by default auth-next is set with Bearer. I fix it by just add the token type to "" (empty string).

My new google auth config was look like:

{
google: {
        responseType: "code",
        clientId:"<google client ID>",
        codeChallengeMethod: "",
        grantType: "authorization_code",
        redirectUri: `${baseUrl}/verify-auth`,
        token: {
          property: "data.token",
          required: true,
          type: "",
          maxAge: 18000,
        }
      }
}