# Cannot read selected organization after login pops up the picker

**URL:** <https://community.auth0.com/t/cannot-read-selected-organization-after-login-pops-up-the-picker/203603>\
**Category:** Get Help\
**Tags:** login\
**Created:** [September 23, 2026, 9:36pm UTC](https://community.auth0.com/t/cannot-read-selected-organization-after-login-pops-up-the-picker/203603 "2026-09-23T21:36:11Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![max17](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/max17/32/80460_2.png) [@max17](https://community.auth0.com/u/max17)\
**Post date:** [September 23, 2026, 9:36pm UTC](https://community.auth0.com/t/cannot-read-selected-organization-after-login-pops-up-the-picker/203603/1 "2026-09-23T21:36:11Z")

</div>

I spent more than 3 days researching this and testing, but I cannot find an answer, and I am not sure it could actually work.

We want to start using organizations. I enabled 2 organizations for my test user, and now, I can see the organizations picker after user/password. In theory, when I pick the organization, it should come in the token as a claim.

The tokens never carry the organization id. I tried to insert the data myself in the post-login trigger. Every other information is carried except for organizations. I have different post-login actions and they work perfectly, for example, we receive if the policies have been accepted from the metadata:

metadata.privacy\_policies

The “Add Organization” action does not yield the information. It seems the data is overridden after I try to set it

```auto
    api.idToken.setCustomClaim(

      "https://cats.dev-thepioneers.com/organizations",

      {

        pioneers_org_id: event.organization.id,

        pioneers_org_name: event.organization.name,

      }

    );    

```

Any other claim works, except for organization information. But I think something is cleared up in the process for organizations only, the log shows me that the data was set (at least the data was valid) in the Successful login event, but a second event (that I don’t understand why it happens) named “Successful Silent Login” does not have the data anymore.

I tried several solutions online, such as reading the organization data in the React hook, but there is no event ever that contains that information. We have nothing in between, the Auth0Provider in React does all the work.

I can add any extra information required in order to understand the issue.

---

<div class="post-metadata">

**Author:** ![gerald.czifra](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/gerald.czifra/32/75301_2.png) [@gerald.czifra](https://community.auth0.com/u/gerald.czifra)\
**Post date:** [September 24, 2026, 9:02pm UTC](https://community.auth0.com/t/cannot-read-selected-organization-after-login-pops-up-the-picker/203603/3 "2026-09-24T21:02:07Z")

</div>

Hi @max17

Welcome to the Auth0 Community!

I understand you are asking why [Organization](https://auth0.com/docs/manage-users/organizations) information set as a custom claim in a post-login action does not appear in your ID token, and why the claim disappears after a “[Successful Silent Login](https://auth0.com/docs/authenticate/login/configure-silent-authentication)” event even though it was successfully set during the initial login.

The root cause is that custom claims set only in the post-login action are not automatically re-applied during silent authentication (token refresh). The “Successful Silent Login” event you see is Auth0 refreshing your tokens using the refresh token flow, which does not re-execute your post-login action with the same context. [Custom claims](https://community.auth0.com/t/an-introduction-to-custom-claims/191589) must either be persisted in user metadata or app\_metadata to survive token refresh, or your action must be designed to retrieve organization data from a persistent source during every token issuance.

**Root Cause:**

When a user logs in silently (via [`getTokenSilently()`](https://auth0.com/docs/libraries/auth0-single-page-app-sdk) or [`checkSession()`](https://auth0.com/docs/libraries/auth0js#using-checksession-to-acquire-new-tokens:~:text=Using%20checkSession%20to%20acquire%20new%20tokens) in your React application), Auth0 uses the refresh token to mint new tokens without re-running the full post-login flow. Your post-login action executes only during the initial interactive login. Any custom claim you set there is included in the first token, but when the token expires and is silently refreshed, the action does not run again with the same `event.organization` context, so the claim is lost.

**Solution:**

To persist organization information across token refreshes, store the organization ID in the user’s app\_metadata during the post-login action, then retrieve it on every token issuance (including silent refreshes). Follow these steps:

1. **Update your post-login action** to store the organization ID in app\_metadata:

```auto
exports.onExecutePostLogin = async (event, api) => {

 if (event.organization && event.organization.id) {

 // Store organization info in app_metadata for persistence

 api.user.setAppMetadata('organization_id', event.organization.id);
 api.user.setAppMetadata('organization_name', event.organization.name);

 }

 // Add to token using the stored metadata (works on initial login)

 const orgId = event.user.app_metadata?.organization_id || event.organization?.id;
 const orgName = event.user.app_metadata?.organization_name || event.organization?.name;

 if (orgId) {

 api.idToken.setCustomClaim(

 'https://cats.dev-thepioneers.com/organizations',

 {

 pioneers_org_id: orgId,
 pioneers_org_name: orgName,

 }

 );

 }

};

```

1. **Verify the claim is namespaced correctly.** Your claim URL `https://cats.dev-thepioneers.com/organizations` is correctly namespaced (Auth0 requires custom claims to use a URL namespace to avoid collisions). This is not the issue.

2. **Decode and inspect both tokens** to confirm the claim appears in the initial ID token. Use a JWT decoder (such as [jwt.io](http://jwt.io)) to verify the claim is present immediately after login.

3. **Check your React application’s token caching.** If you are using the Auth0 React SDK (`useAuth0()` hook), verify that `getIdTokenClaims()` is being called after the initial login completes, not from a cached value. The SDK may cache the decoded token; if the cache is not invalidated after a silent refresh, you may see stale claims.

4. **Test silent authentication in isolation.** Call `getTokenSilently()` directly in your React app and decode the returned token to confirm whether the claim is actually missing from the new token, or whether it is present in the token but not being read by your application.

**Sources:**

- [Customs claims are lost after refresh token](https://community.auth0.com/t/customs-claims-are-lost-after-refresh-token/98791)
- [How can I get organizationId in sisense if I use auth0 with SAML 2](https://community.auth0.com/t/how-can-i-get-organizationid-in-sisense-if-i-use-auth0-with-saml-2/104435)

Hope the above information have helped you overcome the issue, but feel free to reach out to us for any other issue or request!

Have a great one,  
Gerald

---

<div class="post-metadata">

**Author:** ![max17](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/max17/32/80460_2.png) [@max17](https://community.auth0.com/u/max17)\
**Post date:** [September 25, 2026, 2:19pm UTC](https://community.auth0.com/t/cannot-read-selected-organization-after-login-pops-up-the-picker/203603/4 "2026-09-25T14:19:19Z")

</div>

> [@gerald.czifra](#):
>
> ```auto
> const orgId = event.user.app_metadata?.organization_id || event.organization?.id;
> const orgName = event.user.app_metadata?.organization_name || event.organization?.name;
> 
> if (orgId) {
> 
> api.idToken.setCustomClaim(
> 
> 'https://cats.dev-thepioneers.com/organizations',
> 
> {
> 
> pioneers_org_id: orgId,
> pioneers_org_name: orgName,
> 
> }
> 
> );
> 
> ```

Hi! Thank you so much for the response. I tried it right away and it works perfectly. Now I understand the workflow. I will tweak it a bit because I had a different way to read it in the UI, but it makes sense now.  
Thanks!

---

<div class="post-metadata">

**Author:** ![gerald.czifra](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/gerald.czifra/32/75301_2.png) [@gerald.czifra](https://community.auth0.com/u/gerald.czifra)\
**Post date:** [September 25, 2026, 3:32pm UTC](https://community.auth0.com/t/cannot-read-selected-organization-after-login-pops-up-the-picker/203603/5 "2026-09-25T15:32:19Z")

</div>

Hi @max17

Thank you for letting us know, happy to hear it is working for you correctly now!

Wishing you a great weekend ahead,  
Gerald

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [October 5, 2026, 3:32pm UTC](https://community.auth0.com/t/cannot-read-selected-organization-after-login-pops-up-the-picker/203603/6 "2026-10-05T15:32:55Z")

</div>

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.
