Get Username claim in access token

I have a requirement to make username appear in the token as a claim like sub etc., I know this for a fact that it is not a standard, but I fail to find a way to do that. Is it even possible in Okta ?

you can introduce a custom claim into an access token for a custom authorization server in Okta. There you can bind it to user.login if you need it to be like that

Thanks for the reply, but I need to have it as username only, I can’t use it as it is a reserved claim and can not be added as a custom claim, trying different name other than username won’t work as the requirement is having it as username as the name of the claim.

username is a good name for the claim, as it does not intersect with any reserved claim names. And the expression for it will be user.login


This is what I get while creating custom claim.

Wow, that is a surprise to me, honestly. Maybe somebody from Okta folks here can point us to a document describing why username is reserved. Is any other name of your choice working fine?

1 Like

One of my colleagues helped with a link to the list of reserved claims - Token inline hook reference | Okta Developer

2 Likes