timmm | DexFi Gia Dev
timmm | DexFi Gia Dev
Explore posts from servers
CCConvex Community
Created by timmm | DexFi Gia Dev on 2/21/2025 in #general
Using Twitter with Convex Auth
Oh I will change to this. Didn't realise you could do that
78 replies
CCConvex Community
Created by timmm | DexFi Gia Dev on 2/21/2025 in #general
Using Twitter with Convex Auth
Thanks again Tom 🙂 For those coming back here later the full solution was: 1. setup convex auth as per instructions https://labs.convex.dev/auth/setup/manual 2. add the twitter provider to convex/auth.ts
import { convexAuth } from "@convex-dev/auth/server";
import Twitter from "@auth/core/providers/twitter";
import invariant from "tiny-invariant";

const xClientId = process.env.X_CLIENT_ID;
const xClientSecret = process.env.X_CLIENT_SECRET;

invariant(xClientId, "X_CLIENT_ID is not set");
invariant(xClientSecret, "X_CLIENT_SECRET is not set");

export const { auth, signIn, signOut, store, isAuthenticated } = convexAuth({
providers: [
Twitter({
clientId: xClientId,
clientSecret: xClientSecret,
}),
],
});
import { convexAuth } from "@convex-dev/auth/server";
import Twitter from "@auth/core/providers/twitter";
import invariant from "tiny-invariant";

const xClientId = process.env.X_CLIENT_ID;
const xClientSecret = process.env.X_CLIENT_SECRET;

invariant(xClientId, "X_CLIENT_ID is not set");
invariant(xClientSecret, "X_CLIENT_SECRET is not set");

export const { auth, signIn, signOut, store, isAuthenticated } = convexAuth({
providers: [
Twitter({
clientId: xClientId,
clientSecret: xClientSecret,
}),
],
});
3. add a custom schema for users - note that the email needs to be optionally null email: v.optional(v.union(v.string(), v.null()))
users: defineTable({
name: v.optional(v.string()),
image: v.optional(v.string()),
email: v.optional(v.union(v.string(), v.null())),
emailVerificationTime: v.optional(v.number()),
phone: v.optional(v.string()),
phoneVerificationTime: v.optional(v.number()),
isAnonymous: v.optional(v.boolean()),
}).index("email", ["email"]),
users: defineTable({
name: v.optional(v.string()),
image: v.optional(v.string()),
email: v.optional(v.union(v.string(), v.null())),
emailVerificationTime: v.optional(v.number()),
phone: v.optional(v.string()),
phoneVerificationTime: v.optional(v.number()),
isAnonymous: v.optional(v.boolean()),
}).index("email", ["email"]),
4. add the callback URL on twitter to your convex HTTP endpoint. I'm using local dev atm http://127.0.0.1:3211/api/auth/callback/twitter
78 replies
CCConvex Community
Created by timmm | DexFi Gia Dev on 2/21/2025 in #general
Using Twitter with Convex Auth
This is great. Very much appreciated!
78 replies
CCConvex Community
Created by timmm | DexFi Gia Dev on 2/21/2025 in #general
Using Twitter with Convex Auth
You move so quick - thanks heaps Tom
78 replies
CCConvex Community
Created by timmm | DexFi Gia Dev on 2/21/2025 in #general
Using Twitter with Convex Auth
Hey it's working!
78 replies
CCConvex Community
Created by timmm | DexFi Gia Dev on 2/21/2025 in #general
Using Twitter with Convex Auth
ohhhhh
78 replies
CCConvex Community
Created by timmm | DexFi Gia Dev on 2/21/2025 in #general
Using Twitter with Convex Auth
I'm going to keep poking around... using email might not be an issue
78 replies
CCConvex Community
Created by timmm | DexFi Gia Dev on 2/21/2025 in #general
Using Twitter with Convex Auth
78 replies
CCConvex Community
Created by timmm | DexFi Gia Dev on 2/21/2025 in #general
Using Twitter with Convex Auth
I'm guessing that's the way you link multiple accounts or how next auth does it
78 replies
CCConvex Community
Created by timmm | DexFi Gia Dev on 2/21/2025 in #general
Using Twitter with Convex Auth
Can I change email to optional in the schema?
78 replies
CCConvex Community
Created by timmm | DexFi Gia Dev on 2/21/2025 in #general
Using Twitter with Convex Auth
Oh yep I got the same error
78 replies
CCConvex Community
Created by timmm | DexFi Gia Dev on 2/21/2025 in #general
Using Twitter with Convex Auth
Nah it's fine. It's for the auth I'll pull out
78 replies
CCConvex Community
Created by timmm | DexFi Gia Dev on 2/21/2025 in #general
Using Twitter with Convex Auth
it's because I had a folder called auth already
78 replies
CCConvex Community
Created by timmm | DexFi Gia Dev on 2/21/2025 in #general
Using Twitter with Convex Auth
Oh I know why.. nvm
78 replies
CCConvex Community
Created by timmm | DexFi Gia Dev on 2/21/2025 in #general
Using Twitter with Convex Auth
ok this is a bit odd - the signIn function has thrown off all my types Type instantiation is excessively deep and possibly infinite.ts(2589)
78 replies
CCConvex Community
Created by timmm | DexFi Gia Dev on 2/21/2025 in #general
Using Twitter with Convex Auth
Ah of course
78 replies
CCConvex Community
Created by timmm | DexFi Gia Dev on 2/21/2025 in #general
Using Twitter with Convex Auth
I'm guessing the callback url is to the convex server http api?
78 replies
CCConvex Community
Created by timmm | DexFi Gia Dev on 2/21/2025 in #general
Using Twitter with Convex Auth
I'm giving it a go. Will let you know how I go
78 replies
CCConvex Community
Created by timmm | DexFi Gia Dev on 2/21/2025 in #general
Using Twitter with Convex Auth
Oh awesome. Thanks Tom
78 replies
CCConvex Community
Created by timmm | DexFi Gia Dev on 2/21/2025 in #general
Using Twitter with Convex Auth
OK that sounds like a good idea. Is there an example somewhere of adding an Auth.js provider?
78 replies