Enrich JWT with organisation membership info
Hi,
Is there any recommended way to retrieve organisation and membership info for the user and active organisation, when adding JWT claims in 
definePayload? We want to embed eg. the member role in the JWT. I looked at using getFullOrganization , but that doesn't work as we're missing the request headers (or is there a way to access them?).
Best,
/d2 Replies
Hey. Maybe try this? https://www.better-auth.com/docs/plugins/jwt#modify-jwt-payload
this runs server side, so you can call get stuff from there as needed
JWT | Better Auth
Authenticate users with JWT tokens in services that can't use the session
Yes, that's what I do! My main issue was wrapping my head around how to access entities thru better-auth (like users, organizations etc) in a context where there are no headers containing authorization info from the user. Which is the case with 
definePayload, which only passes the user and session but not the context containing request headers. 
The way I understand things now, is that we have to proceed by using API keys in order to be able to retrieve data needed in contexts like this!