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

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

Open
anver opened this issue Jul 28, 2023 · 0 comments
Open

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

anver opened this issue Jul 28, 2023 · 0 comments

Comments

@anver
Copy link

anver commented Jul 28, 2023

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

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