Spioune
Spioune
CCConvex Community
Created by Spioune on 1/1/2025 in #support-community
Custom auth
Hi everyone, I am trying to understand how auth works in convex. I want to implement custom oauth and not use clerk or auth0. What I usually do is I have 2 endpoints per providers. For example, /oauth/google that redirects users to the google login page, and another endpoint /oauth/google/callback that get the user profile and insert it into the database. Then I create a custom JWT, redirect the user to https://frontend/?access_token=***, extract the access_token on the frontend (SPA), store it in local storage, then include it in every requests I make to my API. I know I can create endpoints with http actions (for oauth redirect and callback), store users in the database and generare JWT but is there a way to setup the convex javascript client to send my own JWT on every requests? I tried to use client.setAuth() but it says provider not recognized. My goal is to be able to use convex built in ctx.auth in server functions so that I don't have to fetch the user manually at the beginning of every function.
12 replies