Using Patreon with NextAuth, keeping getting mismatching redirect URI

{"error":"invalid_request","error_description":"Mismatching redirect URI.","state":"odbqmLhfSgx0ueeCW-7g-ptTwtGYEN1ObpZT_llc-jQ"}

I don’t understand why I keep getting this error. I’ve copied and pasted my domain url and have checked several times. I was previously integrating this on a MERN app, everything worked fine there. I’ve since decided to use Next.js for my project, but upon putting together a basic usage of NextAuth with Patreon, I keep getting the mismatching redirect. Are there any known issues using Patreon with Next? Its been difficult to find example code integrating Patreon OAuth. I’ve also confirmed that the client id and secret set as environment variables are correct.

If your site/app allows mixed http:// and https:// urls instead of forcing one, then such issues may end up happening. http:// and https:// urls are treated as different redirect urls.

Figured out the issue. When using NextAuth to integrate Patreon (not sure if this is an issue for other providers, it isn’t for Github), you need to explicitly pass the redirect_uri into the provider like this:

authorization: {
            params: {
               redirect_uri: "https://www.mydomain.com",
               scope: "identity identity.memberships",
               grant_type: "authorization_code",
            },
         },

Unfortunately this isn’t clear in the documentation.

1 Like