NextAuth
Unanswered
Tonkinese posted this in #help-forum
TonkineseOP
Hey,
How can I use the Auth Plugin for Discord?
Tried it multiple times and doesnt get it.
How can I use the Auth Plugin for Discord?
Tried it multiple times and doesnt get it.
77 Replies
TonkineseOP
European sprat
I suggest taking at least a few minutes to share code and some details about the error. No one is going to care to help you if you don't provide even some basic details
TonkineseOP
@European sprat I suggest taking at least a few minutes to share code and some details about the error. No one is going to care to help you if you don't provide even some basic details
TonkineseOP
Thats basically what i found online
Giant panda
You need to way more context. What are the exact steps that trigger the error? Have you tried up/downgrading next-auth to ensure it's not a regression etc.?
TonkineseOP
Just Tried adding Discord.
Error /api/auth/discord
Error /api/auth/discord
Horned Lark
check if your redirect url is correct or not
Ia that right or wrong?
I start my PC, i sent more pictures then ðŸ‘
Horned Lark
i mean in discord developer section
TonkineseOP
Okay, will check that
so testing time
I dont know, if this file structure is alright, is it?
Horned Lark
it should be /api/auth/callback/discord imo
@Horned Lark it should be /api/auth/callback/discord imo
TonkineseOP
Then i get redirected here when going onto callback/discord
But i dont know, why he isnt redirecting me to the Discord Oauth thing
You know what i mean
Horned Lark
can you share your auth logic
code *
TonkineseOP
import NextAuth from 'next-auth'
import Discord from 'next-auth/providers/discord'
export const authOptions = {
providers: [
Discord({
clientId: process.env.DISCORD_CLIENT_ID,
clientSecret: process.env.DISCORD_CLIENT_SECRET
})
]
}
const handler = NextAuth(authOptions)
export {handler as GET, handler as POST}Thats the code in the route.js
Horned Lark
code is looking fine to me
TonkineseOP
Yeah i looked to tutorials and was awake for a long time, but nothing worked
Horned Lark
I'm also trying to fix the firebase auth issue lol
TonkineseOP
You know i bought a Udemy course, watched a little bit and started yesterday my self with next and the experience is so good. But next-auth doesnt work :/
I use the App Router
Horned Lark
try checking the redirect urls on discord dev section
TonkineseOP
Nahh discord api is giving you a error, if the redirects are bad. But it doesnt even go to the discord api page, means it is a next-auth issue i think
Horned Lark
https://spacecases-remake.vercel.app/ this website is also using the app router
TonkineseOP
SSL ERROR 

Horned Lark
😞
@Tonkinese Click to see attachment
TonkineseOP
Better than nothing
Horned Lark
try implementing the auth using pages dir if it works or not
TonkineseOP
I deploy it to vercel and test it first there
then i solve the ssl local eroror
Horned Lark
ok
callbacks: { async redirect({ url, baseUrl }) { return baseUrl }, },Horned Lark
😞
TonkineseOP
got it working locally

Was the Discord Thing
Horned Lark
told ya
TonkineseOP
didnt add http and so it used https automatically
Horned Lark

TonkineseOP
The feeling when you can close 20 Browser Tabs 

Horned Lark
me with 2 desktop screens
TonkineseOP
haha
so know i have to save the session stuff and manage it with a db
Horned Lark
oh
so everything solved now can we close this thread
TonkineseOP
I think so
Horned Lark
shit my mind is about to explode
i forgor
TonkineseOP
what 

Horned Lark
my coffee
TonkineseOP

Horned Lark
what's that
TonkineseOP
the DBs
Horned Lark
GREAT
TonkineseOP
http://localhost:3000/api/auth/signin/discord Doesnt work, because you need to POST for the User to get redirected to discord. is there any way for redirecting there directly? or do i have to make a post button
TonkineseOP
@Horned Lark Is there any way removing this page and redirect directly to discord without making the post request with the button
Horned Lark
ah you can configure the default page
Horned Lark
TonkineseOP
Nothing works
Horned Lark
? 🤔
@Horned Lark ? 🤔
TonkineseOP
Now it does
Horned Lark
so problem solved ?
Original message was deleted
If the problem is solved, please mark it as such