wp-openid-connect-server icon indicating copy to clipboard operation
wp-openid-connect-server copied to clipboard

Error: This action with HTTP GET is not supported by NextAuth.js

Open anver opened this issue 1 year ago • 0 comments

I've configured everything on the WordPress side and seems everything is working perfect, I'm trying to connect using the next auth client and I get this error. When I click the sign in button I get redirected to the url https://mydomain.local/api/auth/callback?code=182cdfefe65de7bc15acb4619e44b6e0ac1a98aa&state=AUDGKCrDKzaNyTLeMf_6J8-3b6jWHd4d24-WTYSsNcE

so the WordPress oauth server is generating the code and while redirecting back to this page it says "Error: This action with HTTP GET is not supported by NextAuth.js"

Below is my next auth route file inside mydomain/app/api/auth/[...nextauth]/route.ts

i'm using

    "next": "13.4.12",
    "next-auth": "^4.22.3",

I'm unsure if this is a next-auth thing or i'm not sending something useful to the WordPress OAuth server

import NextAuth, { NextAuthOptions } from 'next-auth';

const authOptions: NextAuthOptions = {
    providers: [
        {
            id: 'mydomain',
            issuer: 'https://myoauthdomain.com/',
            wellKnown: "https://myoauthdomain.com/.well-known/openid-configuration",
            clientId: "XktKsfkYP2zq6cgaLZbH",
            clientSecret: 'C4EQe4ptNuyR+NsK3vEOhW2dKDEVRpRODXEuZv07bXk=',
            idToken: true,
            name: 'myauthdomain',
            type: 'oauth',
            authorization: {
                url: 'https://myoauthdomain.com/wp-json/openid-connect/authorize',
                params: {
                    scope: "openid profile",
                    redirect_uri: 'https://mydomain.local/api/auth/callback'
                }
            },
            token: {
                url: 'https://myoauthdomain.com/wp-json/openid-connect/token',
                params: {
                    grant_type: 'authorization_code',
                    redirect_uri: 'https://mydomain.local/api/auth/callback'
                },
            },
            profile(profile) {
                return { ...profile }
            },
        },
    ],
    debug: true,
    callbacks: {
        async jwt({ token, account }) {
            return token
        },
        async session({ session, token, user }) {
            return session
        },
    },
}

const handler = NextAuth(authOptions);

export { handler as GET, handler as POST };

am i missing something to pass to the server or is it something related to next-auth thing? please help

anver avatar Jul 28 '23 14:07 anver