Getting orgId from userIdentity does not work
I can't seem to apply my org ID to newly created resources. I'm not sure what I'm doing wrong : I have tried all manner of permutations of the
orgId
field above but it always results in an error either to do with not matching the schema (for the one above), or simply argument validation error with "Object is missing the required field 'orgId'" if I remove the optional, or remove the entry from the args altogether. I have added the claim for org ID in the JWT template that I'm using : and it has saved/persisted in my Clerk config. From the guides I've read, this seems how I should be able to retrieve the org ID, but obviously something's wrong -- any help would be appreciated, thank you.4 Replies
Sounds like you've already tried this, but pointing out you have
org_id
(with an underscore) in your template and orgId
(camel case) in your code, and I believe you want these to match.
In general, I'm a fan of adding a bunch of logging + trying to simplify as much as possible. For instance, I'd probably start with a mutation that just logs ctx.auth.getUserIdentity()
and see if that's what I'd expect. And I'd also potentially try even simpler changes to the clerk config (e.g. adding "foo": "bar"
and seeing that the custom field makes it through to Convex) to narrow down exactly where the problem ishow do you log the execution inside convex .ts files?
Just
convex.log()
works well, in dev you'll see these in the browser. In dev and prod you can see these in the dashboard, and in the CLI npx convex logs
.Thanks for the help @sshader @ballingt