Search code examples
next.jsnext-auth

vk provider Auth.js v5 Next.js 14 Code challenge method error


I'm trying to add oauth using Vk provider.

import NextAuth from "next-auth";
import Credentials from "next-auth/providers/credentials";
import Vk from "next-auth/providers/vk"



export const { handlers, auth, signIn, signOut } = NextAuth({
    pages: {
        signIn: "/auth/login",
    },
    providers: [
        Vk,
        Vk({
            clientId: process.env.AUTH_VK_ID,
            clientSecret: process.env.AUTH_VK_SECRET
        }),
    ]
})

And I'm getting an error {"error":"invalid_request","error_description":"Code challenge method is unsupported"}

I searched and there was a bug report https://github.com/nextauthjs/next-auth/issues/9898 that authorization params include "code_challenge_method":"S256" and by removing it the problem should be fixed but there are no info in the new documentation and old one has only the one sentence about default code_challenge_method and no information on how to change it. i tried manually but nothing helped

authorization: {
        codeChallengeMethod: 'plain'
    }

Solution

  • You can disable checks in NextAuth options like this: enter image description here

    But next you will face another problem, which i try to resolve now.