# How to properly sign in with universal login and organizations

**URL:** <https://community.auth0.com/t/how-to-properly-sign-in-with-universal-login-and-organizations/150009>\
**Category:** Get Help\
**Tags:** new-universal-login-experience, login-experience\
**Created:** [October 16, 2024, 9:19pm UTC](https://community.auth0.com/t/how-to-properly-sign-in-with-universal-login-and-organizations/150009 "2024-10-16T21:19:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![brandon.fleming](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/brandon.fleming/32/59788_2.png) [@brandon.fleming](https://community.auth0.com/u/brandon.fleming)\
**Post date:** [October 16, 2024, 9:19pm UTC](https://community.auth0.com/t/how-to-properly-sign-in-with-universal-login-and-organizations/150009/1 "2024-10-16T21:19:38Z")

</div>

I’m trying to get Universal login working with organizations. I’ve verified that the organization is set up correctly and that my user account has been granted access to the org. I’ve also verified that the organization name I’m passing matches the correct org I wish to access.

I’m using `@auth0/auth0-react@2.2.4`.

```tsx
const AuthProvider = ({ children }) => {
  const navigate = useNavigate()

  const onRedirectCallback = (appState) => {
    navigate(appState?.returnTo || window.location.pathname)
  }

  return (
    <Auth0Provider
      authorizationParams={{
        organization: getOrgId(window.location.hostname) // retrieves the organization name from the subdomain of the hostname
        redirect_uri: window.location.origin,
      }}
      clientId={import.meta.env.VITE_AUTH_CLIENT_ID}
      domain={import.meta.env.VITE_AUTH_DOMAIN}
      onRedirectCallback={onRedirectCallback}
    >
      {children}
    </Auth0Provider>
  )
}

```

The documentation for the `authorizationParams.organization` property states that I can use the organization name:

```ts
/**
     * The organization to log in to.
     *
     * This will specify an `organization` parameter in your user's login request.
     *
     * - If you provide an Organization ID (a string with the prefix `org_`), it will be validated against the `org_id` claim of your user's ID Token. The validation is case-sensitive.
     * - If you provide an Organization Name (a string *without* the prefix `org_`), it will be validated against the `org_name` claim of your user's ID Token. The validation is case-insensitive.
     *
     */
    organization?: string;

```

When redirecting the user to the Universal Login page via `loginWithRedirect`, I’m immediately redirected back my applications login page and I can see two query string values:

```auto
error=invalid_request
error_description=authorization request parameter organization must be an organization id

```

This contradicts the documentation for the AuthProvider. What am I doing wrong?

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [October 17, 2024, 4:20pm UTC](https://community.auth0.com/t/how-to-properly-sign-in-with-universal-login-and-organizations/150009/3 "2024-10-17T16:20:41Z")

</div>

Hi @brandon.fleming,

Welcome to the Auth0 Community!

The documentation for the AuthProvider is correct. The organization can be specified using either the `org_id` or `org_name`.

However, in this context, you must provide the `org_id` in your login request to log in with organizations.

The [AuthorizationParams Interface](https://auth0.github.io/auth0-react/interfaces/AuthorizationParams.html#organization) might also be used in another context like silent authentication, where the user is already authenticated and you are revalidating the session. In this scenario, you could check the `org_name` claim in the ID token.

Thanks,  
Rueben

---

<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 31, 2024, 4:21pm UTC](https://community.auth0.com/t/how-to-properly-sign-in-with-universal-login-and-organizations/150009/4 "2024-10-31T16:21:42Z")

</div>

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