0

I'm using nuxt 3.2.3 with @sidebase/nuxt-auth 0.5.0-rc.0 for authorization.

I defined Google Provider this way:

...
GoogleProvider.default({
  clientId: 'secret.apps.googleusercontent.com',
  clientSecret: 'secret',
  token: {
    url: "https://api.example.com/api/auth/socialite/google"
  }
})
...

So I added token option as it is defined here: https://next-auth.js.org/configuration/providers/oauth#token-option

And also jwt callback:

...
async jwt({ token, account }) {
  if (account) {
    token.jwt = account.id_token
  }
  return token
}
...

Everything works fine like Google authorization and so on, but in the process of authorization I would expect to make an API request to retrieve an access_token from my Laravel application. There are some access_token and id_token in account parameter, but those are not from my application.

I did the same with Nuxt 2 few years ago with some different settings and it worked:

...
google: {
  clientId: 'secret.apps.googleusercontent.com',
  clientSecret: 'secret',
  responseType: 'code',
  codeChallengeMethod: '',
  endpoints: {
    token: 'https://api.example.com/api/auth/socialite/google'

  },
  token: {
    property: 'access_token',
  }
}
...

Am I using the token option the right way?

sunergos
  • 129
  • 2
  • 14

1 Answers1

1

After reading this article I found out the solution for my effort to connect Nuxt and nuxt-auth with separate API server.

The token from my backend application is possible to obtain using signIn Callback. No need to use token option in Google Provider.

sunergos
  • 129
  • 2
  • 14