0

Im using nuxtjs for a while. Before my last update all auth feature run smoothly. But after I update the nuxt.config.js move axios plugin from plugins array to auth config object the error occurred. I need to put axios in auth config object because I need to access $auth from axios plugin.

Version

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

Nuxt configuration

Mode:

  • Universal

Nuxt configuration

  auth: {
    plugins: [{ src: "~/plugins/axios.js", ssr: true }], // <-- I put this, move from plugins array
    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.

1 Answers1

0

Update google auth config like this:

google: {
        responseType: "code",
        clientId:"<google client ID>",
        codeChallengeMethod: "",
        grantType: "authorization_code",
        redirectUri: `${baseUrl}/verify-auth`,

token: {
          property: "data.token", // <-- based on your API response (endpints.login)
          required: true,
          type: "",
          maxAge: 18000,
        },
        user: {
          property: "data",
          autoFetch: true,
        },
        endpoints: {
          login: { url: "{your google auth API}", method: "post" }, // <-- should return response with token on it
          logout: { url: "/api/profiles/logout", method: "get" },
          user: { url: "/api/profile", method: "get" },
        },
      }