Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Google OAuth: Redirect URI mismatch #1

Open
juni0r opened this issue Aug 18, 2024 · 0 comments
Open

Google OAuth: Redirect URI mismatch #1

juni0r opened this issue Aug 18, 2024 · 0 comments

Comments

@juni0r
Copy link

juni0r commented Aug 18, 2024

Hi,

I found your module by chance, trying to integrate Lucia into Nuxt. It works great so far in my own project, except for Google OAuth on callback:

 ERROR  [nuxt] [request error] [unhandled] [500] redirect_uri_mismatch
  at OAuth2Client.sendTokenRequest (./node_modules/.pnpm/[email protected]/node_modules/oslo/dist/oauth2/index.js:99:19)  
  at process.processTicksAndRejections (node:internal/process/task_queues:95:5)  
  at async OAuth2Client.validateAuthorizationCode (./node_modules/.pnpm/[email protected]/node_modules/oslo/dist/oauth2/index.js:59:16)  
  at async Google.validateAuthorizationCode (./node_modules/.pnpm/[email protected]/node_modules/arctic/dist/providers/google.js:23:24)  
  at Object.handler (./node_modules/.pnpm/@[email protected][email protected][email protected]/node_modules/@fixers/nuxt-lucia-auth/dist/runtime/server/providers/google.js:55:22)  
  at async ./node_modules/.pnpm/[email protected]/node_modules/h3/dist/index.mjs:1975:19  
  at async Object.callAsync (./node_modules/.pnpm/[email protected]/node_modules/unctx/dist/index.mjs:72:16)  
  at async Server.toNodeHandle (./node_modules/.pnpm/[email protected]/node_modules/h3/dist/index.mjs:2266:7)

Upon investigation, I found that the provider uses the callback URL from the current request:

// Redirect on this exact endpoint
const redirectUrl = getRequestURL(event).href

However, this includes the query parameters added by Google which need to be removed. Changing this to

const redirectUrl = getRequestURL(event).href.split['?'][0]

will remove the query part of the callback URL and I can authentication works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant