# Single Sign on for Single Page Applications

**URL:** <https://community.auth0.com/t/single-sign-on-for-single-page-applications/83179>\
**Category:** Get Help\
**Tags:** login, auth0\
**Created:** [May 10, 2022, 1:43pm UTC](https://community.auth0.com/t/single-sign-on-for-single-page-applications/83179 "2022-05-10T13:43:50Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![romanmakovyak](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/romanmakovyak/32/37204_2.png) [@romanmakovyak](https://community.auth0.com/u/romanmakovyak)\
**Post date:** [May 10, 2022, 1:43pm UTC](https://community.auth0.com/t/single-sign-on-for-single-page-applications/83179/1 "2022-05-10T13:43:50Z")

</div>

Hello! I am trying to figure out if the following scenario is possible.  
I want to have multiple Single Page Applications with an SSO.

I’ve been trying all different setups in the last couple of days, but nothing seems to work.

My current setup is:

- two SPA (from React quick start) deployed to [app1.domain.com](http://app1.domain.com) and [app2.domain.com](http://app2.domain.com).
- I use a custom domain for authorization: [login.domain.com](http://login.domain.com)
- Each app tries to getAccessTokenSilently upon render.

Whenever I try, I always get an error “Login is required”. Tried Chrome, Firefox, and Safari. All Cookies are allowed in browser settings. I went through posts in this community and it seems like people used to have this issue lately.

I really just want to know if this setup is possible and realistic and maybe what can be fixed to make it work.

[har.txt](https://community.auth0.com/uploads/short-url/sFlA1AyU6hDGjjUYZ3SeEysnaZb.txt) (68.7 KB)

Thank you!

---

<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:** [May 10, 2022, 4:20pm UTC](https://community.auth0.com/t/single-sign-on-for-single-page-applications/83179/3 "2022-05-10T16:20:46Z")

</div>

Hi @romanmakovyak,

Welcome to the Auth0 Community!

> [@romanmakovyak](#):
>
> Each app tries to getAccessTokenSilently upon render.

Unfortunately, using the getAccessTokenSilently method will always trigger the [“Login is required” error message](https://auth0.com/docs/authenticate/login/configure-silent-authentication#error-responses) if the user was not previously signed in or if their session has expired.

This method should only be used for [Silent Authentication](https://auth0.com/docs/authenticate/login/configure-silent-authentication) to refresh a user’s session without prompting them for credentials again. Moreover, the user must be logged in for silent authentication to work.

In this case, I recommend using the Universal Login for SSO across your different Single Page Applications.

See [How do I configure (SSO) Single Sign-On with Auth0?](https://community.auth0.com/t/how-do-i-configure-sso-single-sign-on-with-auth0/82450) to learn more.

Please let me know if you have any questions.

Thank you.

---

<div class="post-metadata">

**Author:** ![romanmakovyak](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/romanmakovyak/32/37204_2.png) [@romanmakovyak](https://community.auth0.com/u/romanmakovyak)\
**Post date:** [May 10, 2022, 5:48pm UTC](https://community.auth0.com/t/single-sign-on-for-single-page-applications/83179/4 "2022-05-10T17:48:24Z")

</div>

Thanks @rueben.tiow ! I forgot to mention one step in between 🙂 When I Iogin to one of the apps, it’s not reflected in another application. getAccessTokenSilently is a bad example 🙂

---

<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:** [May 10, 2022, 7:24pm UTC](https://community.auth0.com/t/single-sign-on-for-single-page-applications/83179/5 "2022-05-10T19:24:06Z")

</div>

Hi @romanmakovyak,

Thank you for your response and clarification.

> [@romanmakovyak](#):
>
> When I Iogin to one of the apps, it’s not reflected in another application. getAccessTokenSilently is a bad example 🙂

In this case, could you please clarify if you are using the Universal Login experience?

And are both applications on the same tenant?

Thank you.

---

<div class="post-metadata">

**Author:** ![romanmakovyak](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/romanmakovyak/32/37204_2.png) [@romanmakovyak](https://community.auth0.com/u/romanmakovyak)\
**Post date:** [May 11, 2022, 8:29am UTC](https://community.auth0.com/t/single-sign-on-for-single-page-applications/83179/6 "2022-05-11T08:29:07Z")

</div>

Both apps are on the same tenant, I am using UL experience.

---

<div class="post-metadata">

**Author:** ![romanmakovyak](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/romanmakovyak/32/37204_2.png) [@romanmakovyak](https://community.auth0.com/u/romanmakovyak)\
**Post date:** [May 11, 2022, 8:37am UTC](https://community.auth0.com/t/single-sign-on-for-single-page-applications/83179/7 "2022-05-11T08:37:24Z")

</div>

Actually, I just figured something out. SSO does work for me as expected if I disable organizations on my applications. How do I make it work with organizations?

---

<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:** [May 17, 2022, 12:45am UTC](https://community.auth0.com/t/single-sign-on-for-single-page-applications/83179/8 "2022-05-17T00:45:44Z")

</div>

Hi @romanmakovyak,

Thank you for your response.

After my investigation, I did not find the same observations as you. Instead, I found SSO working with both Organizations enabled or disabled.

With that, I can confirm that SSO works with Organizations.

I suggest looking through [How do I configure (SSO) Single Sign-On with Auth0?](https://community.auth0.com/t/how-do-i-configure-sso-single-sign-on-with-auth0/82450) again to set up your SSO correctly.

If you continue having issues, please [capture a HAR file](https://auth0.com/docs/troubleshoot/troubleshooting-tools/generate-and-analyze-har-files) of the complete authentication requests.

Thank you.

---

<div class="post-metadata">

**Author:** ![romanmakovyak](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/romanmakovyak/32/37204_2.png) [@romanmakovyak](https://community.auth0.com/u/romanmakovyak)\
**Post date:** [May 17, 2022, 10:04am UTC](https://community.auth0.com/t/single-sign-on-for-single-page-applications/83179/9 "2022-05-17T10:04:45Z")

</div>

For the case when an organization is preset for the application, I confirm, that SSO does work.  
But for the use case when **both** SPA’s have “Display Organization Prompt” enabled, SSO does not work.  
Did you check this scenario as well?

---

<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:** [May 20, 2022, 5:42pm UTC](https://community.auth0.com/t/single-sign-on-for-single-page-applications/83179/10 "2022-05-20T17:42:08Z")

</div>

Hi @romanmakovyak,

Thank you for your response.

> [@romanmakovyak](#):
>
> But for the use case when **both** SPA’s have “Display Organization Prompt” enabled, SSO does not work.  
> Did you check this scenario as well?

Yes, I did check this scenario, and SSO will continue to work even with the _Display Organization Prompt_ enabled. However, you must specify the `organization` query parameter in the request for SSO to work.

If the `organization` query parameter is not specified, the application will display the organization prompt, thus disrupting the SSO flow and asking the user for credentials again.

Hoped this helps clarify how SSO works with Organizations.

Please let me know if there is anything else I can do to help.

Thank you.

---

<div class="post-metadata">

**Author:** ![romanmakovyak](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/romanmakovyak/32/37204_2.png) [@romanmakovyak](https://community.auth0.com/u/romanmakovyak)\
**Post date:** [May 20, 2022, 6:54pm UTC](https://community.auth0.com/t/single-sign-on-for-single-page-applications/83179/11 "2022-05-20T18:54:22Z")

</div>

Thank you!

Yes, that’s the behaviour I get as well 🙂

Maybe this could be documented somewhere, this could save people some time figuring it out in the future. In this case, the only viable scenario is to implement Display Organization Prompt by ourselves by using Management API.

---

<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:** [May 20, 2022, 7:26pm UTC](https://community.auth0.com/t/single-sign-on-for-single-page-applications/83179/12 "2022-05-20T19:26:31Z")

</div>

Hi @romanmakovyak,

Thank you for your response.

Sure that sounds good, I will pass this feedback along to our Docs team.

Please reach out if you have any further questions.

Thank you!

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [December 21, 2022, 5:21pm UTC](https://community.auth0.com/t/single-sign-on-for-single-page-applications/83179/14 "2022-12-21T17:21:29Z")

</div>

Previous message deleted due to SPAM reasons

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [December 21, 2022, 5:21pm UTC](https://community.auth0.com/t/single-sign-on-for-single-page-applications/83179/15 "2022-12-21T17:21:48Z")

</div>


