DaveIdito
DaveIdito

Reputation: 1606

Nuxt Auth strategy doesn't fetch authentication token

I have the following authentication strategy:

auth: {
    strategies: {
      local: {
        ...,
      },
      google: {
        clientId:
          "<MY CLIENT ID>",
        responseType: "code",
        endpoints: {
          token: "http://localhost:8000/social-login/google/",
          userInfo: "http://localhost:8000/auth/user/",
        },
      },
    },
    redirect: {
      ...
    },
  },

Oddly enough, this strategy completes all the authentication by itself, without ever hitting my backend! Shouldn't responseType code go to endpoints.token to get the token?

My login function looks like this:

    loginWithGoogle() {
      this.$auth.loginWith("google", {
        params: {
          client_id:
            "<MY CLIENT ID>",
        },
      });
    },

Interestingly enough, if I don't pass the params here, Google gives me an error that client_id is missing.

Upvotes: 0

Views: 971

Answers (2)

Andrey Andreata
Andrey Andreata

Reputation: 1

Documentation is wrong. Use client_id , redirect_uri , etc, snake case instead, this worked for me

Upvotes: 0

DaveIdito
DaveIdito

Reputation: 1606

This is a problem with @nuxtjs/auth, which is the version <= v4.9.1, and as the documentation warns that it may contain bugs and un-implemented functionalities.

Using v5, named @nuxtjs/auth-next would fix the issue.

Install as:

yarn add --exact @nuxtjs/auth-next

Then add to your nuxt.config.js as (from the documentation):

{
  modules: [
    '@nuxtjs/auth-next'
  ],
  auth: {
    // Options
  }
}

Upvotes: 1

Related Questions