How to add custom user attribute to token header?

Is it possible to add a custom user attribute to jwt token header?

Already know how to add it in the token claims but was’t able to find any information on how to add it in the header instead.

I don’t think it’s possible with Okta. But what’s the use case?

I’m implementing multi-tenant DB connection and based on the user signing in, my application should know which DB schema to connect to.

Example:
String tenantName = req.getHeader(“X-TenantID”);
TenantContext.setCurrentTenant(tenantName);

OK, but it’s not a JWT header. What you are showing is HTTP header. Still don’t think you can do it with Okta APIs. Why don’t you want to have this info inside JWT as a user claim?

2 Likes

I haven’t been able to get user claims from HttpServletRequest. Only header values for now.
I’ll do more research and try to use user claims instead.