Convex Auth Google OAuth
Hello I've tried looking in the docs and can't find any relative to this problem. I'm trying to separate name and last name from Google Auth but when I do this code it doesn't let me login nor create new user.
any idea for this?
this is my custom schema for user
30 Replies
Yeah I already saw that GoogleProfile Types, maybe I mistype the lastname because of github example. I'll try that later.
Btw is there no wrong with my code? Ia just the family_name instead of last_name?
There's no
id
or image
field either unless there's some type extending that I missed in the source. Looks right, but if it's not logging the user in then something is off.
Can you verify that there are no runtime or type errors on login?
(or sign up)If I didn't include id it will retrieve it by default ? there's a picture in google tho.
It's supposed to deep merge, but the type does not include an id field. Google has
picture
, you used image
.yeah I have image in my DB and I call is that wrong? Should I change my schema to picture also?
Oh I was misreading, sorry - yeah you're fine there, just the keys on
profile
need to match the provider type
The typos in your code are give_name
-> given_name
, and last_name
-> family_name
. You're spreading the profile so you don't need to explicitly add id
.still this doesn't let me login.
I also add firstname in my schema, and even with or without spreading prof still doesn't work
I am using, App Router with SSA. normal Google provider works perfectly.
Can you give more info to help me understand what's happening. When you say it's not logging in, is there an error, what specifically is happening
there's no error, its just not redirecting to my dashboard and also did not create new user. Its like nothing happen
why tagged this as resolve? I still can't set user firstname and lastname from google.
Not sure why it got tagged resolved
Just thinking how to narrow down possible causes. You mentioned it works if you don't pass a config, so try passing a minimal config. Like just a profile function that returns the profile unchanged.
Does your schema have a
firstname
field?
Have you been looking at your Convex dashboard logs to see what errors you're getting?
https://dashboard.convex.dev/deployment/logsConvex Dashboard
Manage your Convex apps
Yup, I changed my schema
Yeah, it works without a config. Now I just made user onboard to make sure that they can fill up firstname and lastname.
What errors are you seeing on your Convex dashboard?
I also tried to spread prof
You must return an
id
which is a string from the profile
method.should I return id like this ? if then I will update my schema to have id and _id ?
id
goes to the authAccounts
, it doesn't flow to the users table (this is not very clear tbh).yeah, even I followed Authjs instructions, I still getting the same error. Maybe I should go with onboarding for a while.
@Kıte are you still blocked?
yep
I'm using @convex-dev/auth 0.0.55
It shouldn't matter but upgrade to latest.
Then let me know what error you're getting in your Convex dashboard.
And please share your Google provider setup from
auth.ts
When I start clicking google login button it shows the 302 error from "api/auth/signIn/*"
when I select google account the other 2 error will show.
Try this:
(You can console.log the
prof.sub
to check it's a string, but I suspect the above will unblock you)it can't detect id because I don't have id in my schema, (actually I already done this.)
and return false
I also even try .toString() or as String.
I think it's a string already. The check would be
console.log(typeof prof.sub === "string")
. But if it wasn't a string you'd get a specific error message about it.
The other error can be unrelated. Can you clear any auth documents and try the flow from scratch?
I expect the "nonexisting document" error is coming from account linking. You have an account in the authAccounts table pointing to a deleted user.
If you delete a user you must also delete all its accounts. (something the library should provide an affordance for, that's tbd)thanks, I didn't realize clrearing docs will solve the problem