#Hey there
1 messages · Page 1 of 1 (latest)
This is what I see after signing in:
No error message, just this warning:
Now comes the strange part.
If for some reason, for example, I remove the signIn() callback, it works and i log in correctly in NextJS
To me, it seems like this code should be done in the signIn event. The error message is in regards to the return true; statement at the bottom of the callback
but the signIn callback, according to the docs, has to return true in case the user is allowed to signIn
for some reason, the await console.log(response); is not even printing anything. and the backend is not even receiving the request
Oh I see what you're doing
You're just missing a step
Callbacks are asynchronous functions you can use to control what happens when an action is performed.
Basically what's happening currently is your provider completes sign-in and redirects to your app. Since you're authenticating with a Provider and not with Credentials or Email, the signIn callback is never triggered.
Wherever you're doing the signIn() function at, just make sure you don't pass a provider parameter. I assume right now it's signIn('google') or something like that. Then, you'll need to define a credential or email provider for your custom accounts in the DB. From there, it should start triggering the callback to determine if the user can or cannot sign in
Yeah. I am using signIn('google').
But the idea I had was to not use a credential or email provider because I just wanted to use Google and Facebook as providers and then send the email of the authenticated user to the backend and create a new database entry with that
I don't want to use custom accounts for now
I was actually following this post:
https://dev.to/ifennamonanu/building-google-jwt-authentication-with-nextauth-5g78
where the guy performs exactly what I wanted
but it doesn't seem to work for me
Google and Facebook will handle if a user is allowed to sign in or not, those providers will never trigger the signIn() callback simply because they do it on their own, and that logic is unnecessary. If you still want to make a call to your database after signIn, you should do so using the signIn() event
Ill make a quick test with the signIn event and report back here
I actually remember I tried this like two days ago and saw the same error message
The connectivity between my NextJS app and my Spring boot backend works fine because I've tested other endpoints in other parts of my app
the error points here:
https://next-auth.js.org/errors#sign_in_event_error
but there is no doc related to that
This is a list of errors output from NextAuth.js.
Your springboot backend doesn't require credentials to post to?
Quickly with that, your postman is a GET request and your axios is a POST request
Change postman to POST and re-verify
yeah true, but it should give another type of error
im trying anyway
also fyi:
signIn callback does actually get called even with GoogleProvider
check "hello" being printed
Hm, that is the exact opposite of the next-auth docs
In that case, I can only image that something is wrong with the axious request
tried with GET in the event, still same error
something seems wrong here
why isn't the axios request going through, so strange
When you did a POST on postman, did that go through?
oh no, but atleast you get an answer by the server:
Maybe Sprintboot requires a PUT
imma try to downgrade node
since im using node 18
Before you do, according to that post you can just change localhost:8080 to 127.0.0.1:8080, that's a quick attempt
Otherwise, downgrading may not be a bad option as long as it doesn't break other things haha
nah no luck
this sucks
specially when theres legit no one else facing the same issue in the whole internet haha
and when there is a guide where the guy is doing the same that i intend to:
https://dev.to/ifennamonanu/building-google-jwt-authentication-with-nextauth-5g78
Ok this is why I definetly need to buy a mac already
turns out I was running my spring boot backend server under the IntelliJ IDE (on windows), and my NextJS app under WSL2 (ubuntu). Apparently, from WSL to the Windows host there is no connection by using "localhost". I had to use the static local ip instead like "http://192.168.1.39:8080/v1/auth/login"
Imagine spending 8h+ days stuck in something like this, trying legit everything possible
How frustrating