Exploring Next-Auth / Google login

37 Views Asked by At

While trying this project: https://github.com/nextauthjs/next-auth-example to see how next-auth works and how to use it for me.

I want to implement the simple case of Google only authentication.

For that I eliminated from auth.ts everything except Google, as a consequence, this is the result:

import NextAuth from "next-auth"
import Google from "next-auth/providers/google"
import type { NextAuthConfig } from "next-auth"

export const config = {
  theme: {
    logo: "https://next-auth.js.org/img/logo/logo-sm.png",
  },
  providers: [
    Google,
  ],
  callbacks: {
    authorized({ request, auth }) {
      const { pathname } = request.nextUrl
      if (pathname === "/middleware-example") return !!auth
      return true
    },
  },
} satisfies NextAuthConfig

export const { handlers, auth, signIn, signOut } = NextAuth(config)

And app/api/auth/[...nextauth]/route.ts contains:

import { handlers } from "auth"
export const { GET, POST } = handlers

When I then run the app locally and try to sign in, I see the display below:

Access blocked: Authorization Error
[email protected]
The OAuth client was not found.
If you are a developer of this app, see error details.
Error 401: invalid_client

I just used my standard Google account to log in.

What did I miss ?

0

There are 0 best solutions below