Next.js Discord

Discord Forum

discord authentication

Answered
!isColonel posted this in #help-forum
Open in Discord
what? all i did was click signin after setting up nextauth
Answered by Anay-208
here is my .env
NEXT_AUTH_URL=http://localhost:3000
CLIENT_ID=MY_CLI_ID
CLIENT_SECRET=SECRET
View full answer

94 Replies

why do i get this
@!isColonel why do i get this
Its because you are redirecting to https
You have to redirect to http if you're doing in localhost
change it in the dev portal ya?
ya, change redirect url both in dev portal and code(if needed)
i mean
ya like this
and i still get that error
@!isColonel and i still get that error
sent the url discord redirected you to
:Thonk:
@!isColonel https://localhost:3000/api/auth/signin/discord
ya, its redirecting to https
can you send your code?
the route?
yes
ill spare you the code block
@!isColonel https://sourceb.in/exSxgZ9cH4
use some other. this one is stuck on loadin
nvm loaded
Also the code where you're redirecting the user
im not
i have none to do that
its that route and this
for layout,tsx
thats all for nextauth
so how are you giving the user an authorization uri
im not giving them one ig
thought once i hit signin, auth handled the rest
So I need code of the page where there is signin
its nextauths default signin
i didnt code it
oh
like its stuck saying this
for callback
are you sure you've only one callback url in discord(for now), which is http://localhost:3000/api/auth/signin
in the dev portal yes
its this in the dev portal
basically doin this in the discord side tho https://www.youtube.com/watch?v=md65iBX5Gxg&t=381s
in .env
what is this
... idk where did you find this
it was in the bar when i hit login
no redirect or anything
after setting the .env?
I guess remove the .env
that one.
one min I'll use your code in local and see the issue
@!isColonel your next-auth and nextjs version
what the hell
so
localhost is https
no http
rlly?
what about a regular site
localhost must be http
in regular site, there is a SSL cert so it'll be https
regular site is https
and localhost is http, because it has no ssl certificate
yes
if i push this to production, due to ssl and ddos records, would this still work?
apparently for this i just had to change the https to http on localhost
For production, there needs to be different redirect uri
@Anay-208 and localhost is http, because it has no ssl certificate
unless it just picks what i put as the uri in the dev portal, correct?
You've to put the uri both in dev portal, and in next auth I think
well in the .env in my files i just put
thats the callback url after authentication ig?
yes
it'll add the
/api/auth/signin
in prod, you set to current uri like https://domain.com
ok well sry to waste your time for my stupidity lmao
@Anay-208 in prod, you set to current uri like `https://domain.com`
yes. i use Clerk but i cant get what i need so im trying this. thanks
1 min I'm seeing
@!isColonel its working for me
here is my .env
NEXT_AUTH_URL=http://localhost:3000
CLIENT_ID=MY_CLI_ID
CLIENT_SECRET=SECRET
Answer
this is callback uri
and same code
Ok sweet thanks. I appreciate it
check it.
It works
alright, mark my message as a solution
Also one other question, when i get authenticated, can i use a session id as an accessToken to request the guilds from https://discord.com/api/users/@me/guilds or should I request a token from discord api as well?
Or is there a way to get the accessToken from somewhere else in NextAuth
Ahh. Ok. Ty