Automattic / Automattic/wp-openid-connect-server

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

Open
#94 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
44
Forks
13
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

Open the contributing guide

Research direction

Start with the reported mydomain/app/api/auth/[...nextauth]/route.ts configuration and trace the callback request returned by the WordPress OpenID Connect authorize endpoint. Compare the callback, authorization, and token URLs with the server's documented flow and NextAuth.js 4.22.3 behavior. Done means the sign-in callback completes without the HTTP GET error, with the relevant request and response details documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
next.js, php, typescript, wordpress
Domain
api, authentication
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.