adelin-bA
Convex Community11mo ago
1 reply
adelin-b

ContextHttpClient, setAuth, cannot get user from ctx

So im trying to call a query from the http client, and this query will need to be auth because we want to access ctx.getIdentity inside.

    const convexHttpClient = new ConvexHttpClient(
      process.env.NEXT_PUBLIC_CONVEX_URL!,

    );

   convexHttpClient.setAuth(config.authToken); // good token with template: "convex" that works when calling httpAction
    

    const decks = await convexHttpClient.query(api.decks.list, {
      organizationId: config.organizationId || null,
    }); 
// ERROR inside the deck list query : const identity = await ctx.auth.getUserIdentity(); is NULL, expecting user 

    return decks;

It seems that setAuth do nothing, how do I access ctx inside my deck.list query to have the user identity
Was this page helpful?