# Server-side redirect for Auth0 Organization login in nodejs/express app

**URL:** <https://community.auth0.com/t/server-side-redirect-for-auth0-organization-login-in-nodejs-express-app/74627>\
**Category:** Get Help\
**Created:** [December 10, 2021, 4:24pm UTC](https://community.auth0.com/t/server-side-redirect-for-auth0-organization-login-in-nodejs-express-app/74627 "2021-12-10T16:24:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![yossarian21](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/yossarian21/32/33668_2.png) [@yossarian21](https://community.auth0.com/u/yossarian21)\
**Post date:** [December 10, 2021, 4:24pm UTC](https://community.auth0.com/t/server-side-redirect-for-auth0-organization-login-in-nodejs-express-app/74627/1 "2021-12-10T16:24:28Z")

</div>

I am relatively new to Auth0 but have experience building identity services. I am trying to do something that seems simple but I am struggling with the impl.

In our nodejs express multi-tenant app, I would like to expose an endpoint like /customer/:name/login that will redirect the user to their Auth0 Organization login page. I already have Organizations configured. In our database, we will associate customer name with organization ID, so I have access to the Auth0 org ID on the server. The flow I want is GET `/customer/:name/login` → look up org ID → redirect to Auth0 login → redirect to app callback page.

The [Auth0 documentation](https://auth0.com/docs/authorization/flows/authorization-code-flow) refers to calling the `authorize` endpoint but delegates the details to an Auth0 SDK. I looked at these libraries:

- `passport-auth0`: I am not excited about the [session requirement](http://www.passportjs.org/packages/passport-auth0/#customization) when using `passport-auth0`; this is a new dependency our app does not currently have.
- `express-openid-connect`: Simpler than passport config, and also handles the session requirement by storing state in encrypted cookies. This [blog](https://auth0.com/blog/auth0-s-express-openid-connect-sdk/) suggests preferring `express-openid-connect` for new projects as a replacement for `passport-auth0`; however, I can’t find a way to specify an organization ID to `express-openid-connect`.

I feel like I’m overcomplicating this; can you help clarify which library would be better for my use case and provide any implementation tips?

---

<div class="post-metadata">

**Author:** ![yossarian21](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/yossarian21/32/33668_2.png) [@yossarian21](https://community.auth0.com/u/yossarian21)\
**Post date:** [December 13, 2021, 8:01pm UTC](https://community.auth0.com/t/server-side-redirect-for-auth0-organization-login-in-nodejs-express-app/74627/2 "2021-12-13T20:01:06Z")

</div>

I ended up using `express-openid-connect` and found I can pass the claim I want to it:

```auto
res.oidc.login({
    authorizationParams: {
        organization: <organization_id>
    }
})

```

---

<div class="post-metadata">

**Author:** ![wescrow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/wescrow/32/37242_2.png) [@wescrow](https://community.auth0.com/u/wescrow)\
**Post date:** [May 11, 2022, 6:48pm UTC](https://community.auth0.com/t/server-side-redirect-for-auth0-organization-login-in-nodejs-express-app/74627/3 "2022-05-11T18:48:02Z")

</div>

This really should be added to the official documentation. It is very, very absent from the quickstart and the **[express-openid-connect](https://github.com/auth0/express-openid-connect)** doc.

---

<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:** [January 10, 2023, 5:21pm UTC](https://community.auth0.com/t/server-side-redirect-for-auth0-organization-login-in-nodejs-express-app/74627/4 "2023-01-10T17:21:32Z")

</div>

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