Hey, I am using Okta with following user mapping to add custom attributes to User Raw JSON:
I confirmed this works. After I log in, this is my Raw JSON:
I need to assign federated_groups
to the accessToken. I want to do this inside an Action. But it lacks some attributes including federated_groups
. Here’s what gets printed when I do console.log(event.user)
:
{
app_metadata: { authorization: [Object] },
created_at: '2023-07-19T19:12:02.556Z',
email_verified: false,
email: 'dominik.jasek@customink.com',
family_name: undefined,
given_name: undefined,
identities: [ [Object] ],
last_password_reset: undefined,
name: 'Dominik Jasek',
nickname: 'dominik.jasek',
phone_number: undefined,
phone_verified: undefined,
picture: 'https://s.gravatar.com/avatar/6f3ee8d81992f41eca8a657a7d069ef7?s=480&r=pg&d=https%3A%2F%2Fcdn.auth0.com%2Favatars%2Fdj.png',
updated_at: '2025-01-13T10:05:28.845Z',
user_id: 'okta|customink-okta|00u2nwefd4MOMlGPk697',
user_metadata: {},
username: 'dominik.jasek@customink.com',
multifactor: []
}
Any ideas how to do that?
Hi @dominikjasek ,
Thank you for reaching out!
You can add custom claims to an Access token through Actions with the following function:
api.accessToken.setCustomClaim(name, value);
You can find more details in our following Knowledge Article right here .
Also, this doc could also serve useful in regards to Action triggers in a post-login Action : Actions Triggers: post-login - Event Object
Hope this helped!
Gerald
Hey @gerald.czifra
Thank you, but that doesn’t answer my question.
How do I get the value in here?
api.accessToken.setCustomClaim(name, value);
event.user
doesn’t contain custom attributes from RAW json.
dominikjasek:
{
app_metadata: { authorization: [Object] },
created_at: '2023-07-19T19:12:02.556Z',
email_verified: false,
email: 'dominik.jasek@customink.com',
family_name: undefined,
given_name: undefined,
identities: [ [Object] ],
last_password_reset: undefined,
name: 'Dominik Jasek',
nickname: 'dominik.jasek',
phone_number: undefined,
phone_verified: undefined,
picture: 'https://s.gravatar.com/avatar/6f3ee8d81992f41eca8a657a7d069ef7?s=480&r=pg&d=https%3A%2F%2Fcdn.auth0.com%2Favatars%2Fdj.png',
updated_at: '2025-01-13T10:05:28.845Z',
user_id: 'okta|customink-okta|00u2nwefd4MOMlGPk697',
user_metadata: {},
username: 'dominik.jasek@customink.com',
multifactor: []
}
Ok I figured out this. For some reason, Auth0 action didnt log federated_groups
here, but it was indeed present. Not sure why but now I am able to assign it to both idToken and accessToken.