Next.js Discord

Discord Forum

Next Auth Discord

Unanswered
American Fuzzy Lop posted this in #help-forum
Open in Discord
American Fuzzy LopOP
I keep getting https://next-auth.js.org/errors#oauth_callback_error invalid_client, when I try to login with discord on next auth... My github login is no problem.
redirectUrl = http://localhost:3000/api/auth/callback/discord

const authOptions: NextAuthOptions = {
    secret: process.env.NEXTAUTH_SECRET,
    providers: [
        GithubProvider({
            clientId: process.env.GITHUB_APP_CLIENT_ID as string,
            clientSecret: process.env.GITHUB_APP_CLIENT_SECRET as string,
        }),
        DiscordProvider({
            clientId: process.env.DISCORD_APP_CLIENT_ID as string,
            clientSecret: process.env.DISCORD_APP_CLIENT_SECRET as string
        })
    ],
    session: {
        maxAge: 24 * 3600, 
    },
};

10 Replies

Red-winged Blackbird
Hi @American Fuzzy Lop, I have the same problem currently. Have you found a solution with your Discord authentication ?
American Fuzzy LopOP
Nah
Common Murre
is your client secret valid?
American Fuzzy LopOP
Mine was
see the example, and double check your settings
Harrier
I also had an issue and it turned out that I had an invalid callback URL.

What worked for me is to set the redirect to:
http://localhost:3000/api/auth/callback/discord
and also modify the "Default Authorization Link" to "Custom URL" and also paste the link there.
@American Fuzzy Lop Nah
Red-winged Blackbird
I found my solution ! Turns out even when I only needed the guilds scope, I also had to add the Identify scope. Then the error just stopped popping
@Red-winged Blackbird I found my solution ! Turns out even when I only needed the guilds scope, I also had to add the Identify scope. Then the error just stopped popping
American Fuzzy LopOP
Thx, not needed anymore but if I ever have another project with Discord Authentication it will come handy!
Red-winged Blackbird
Sure ! Might help as well anyone who crosses this topic 😊