I am using a react application and made a login according to the tutorial. I get a “org_id” parameter on user, but I’m not able to access it’s organization name.
is there any way to achieve that?
Hi @omer2
Thanks for reaching out to Auth0 Community!
Are you looking to add organisation name in id token or access token, Is this something your looking for?
Then go to tenant setting>advanced>scroll down and enable “add organisation into authentication api” this will add org name along with org id in your id and access token. please refer this documentation for more information.
or if you want to get the organisation name in your Actions, then use event.organisation.name
exports.onExecutePostLogin = async (event, api) => {
const organisationName = event.organization?.name;
console.log(event.organization?.name);
}
Hey @pavan.bn.
Thanks for the response.
I am using the auth0 react library and using useAuth0
. is there a method to get org name from there?
Oh I found it! it is on the user
object.
Is there a way to get the organizaiton picture as well?
Hi @omer2,
Obtaining the organisation picture directly is not possible. One approach I tried is retrieving the organisation name (event.organisation.name) in the actions. Then implement an if condition to compare retrieved name with the hard coded org name. If the user is associated with that specific organisation, you can add the organisation’s logo URL to the user metadata using (api.user.setUserMetadata).
Regards,
Pavan.