There have been queries about this before but could I please have clear and fairly complete example of how to add username to the ID Token in Auth grant flow with PKCE. I think I appreciate why it is not there as a default but this would be helpful to us. I don’t understand the use of namespace in the example answers, I think it’s to prevent collisions on claim name “username” as it is not a standard claim. Is that the case, so that the URL can be something idealised ? Does the namespace need to be a URL or can it be a URI ?
Hey there @david-gibbs-ig !
username
isn’t a restricted claim, so you should be able to add it in an ID token without issue - A custom namespace can be a URI or URL but neither are required. For example, the following Post Login action code should add a user’s username
to their ID token without defining a namespace:
exports.onExecutePostLogin = async (event, api) => {
if (event.authorization) {
api.idToken.setCustomClaim('username', event.user.username)
}
}
Hope this helps to clarify!
1 Like
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.