# OKTA SSO login through Angular SPA application

**URL:** <https://devforum.okta.com/t/okta-sso-login-through-angular-spa-application/23525>\
**Category:** OAuth/OIDC\
**Created:** [March 3, 2023, 4:08pm UTC](https://devforum.okta.com/t/okta-sso-login-through-angular-spa-application/23525 "2023-03-03T16:08:09Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![pmoda](https://avatars.discourse-cdn.com/v4/letter/p/7bcc69/32.png) [@pmoda](https://devforum.okta.com/u/pmoda)\
**Post date:** [March 3, 2023, 4:08pm UTC](https://devforum.okta.com/t/okta-sso-login-through-angular-spa-application/23525/1 "2023-03-03T16:08:09Z")

</div>

Hi, I have requirement to access a website both directly and through SSO. Built it on Angular SPA and have okta sign in widget in it. direct login works just fine. But SSO does not. I am fairly new to OKTA integration and Angular. Can you please help guide me toward any article or suggestions on how to achieve this? Client and we have OKTA IDP set up and I was told setup is fine (I don’t have access to it)

---

<div class="post-metadata">

**Author:** ![adam\_okta](https://avatars.discourse-cdn.com/v4/letter/a/f6c823/32.png) [@adam\_okta](https://devforum.okta.com/u/adam_okta)\
**Post date:** [March 3, 2023, 4:20pm UTC](https://devforum.okta.com/t/okta-sso-login-through-angular-spa-application/23525/2 "2023-03-03T16:20:59Z")

</div>

Here are a couple of guides that you might find helpful:

- [Add user authentication to your Angular app](https://developer.okta.com/code/angular/): This is a collection of resources that help you integrate with Okta using the Okta-hosted Sign-In Widget using OpenID Connect (OIDC) client libraries. It includes a quickstart, a sample app, and SDK documentation.
- [Sign users in to your SPA using the redirect model](https://developer.okta.com/docs/guides/sign-into-spa-redirect/angular/main/): This is another guide that shows how to use OIDC to sign users in to your SPA using the redirect model. It also explains how to handle tokens, secure routes, sign users out, and revoke tokens.

---

<div class="post-metadata">

**Author:** ![pmoda](https://avatars.discourse-cdn.com/v4/letter/p/7bcc69/32.png) [@pmoda](https://devforum.okta.com/u/pmoda)\
**Post date:** [March 3, 2023, 4:25pm UTC](https://devforum.okta.com/t/okta-sso-login-through-angular-spa-application/23525/3 "2023-03-03T16:25:44Z")

</div>

Thank you for replying Adam. I checked both of them when developing. when I click on website widget from okta app, it is taking to the website but its asking for username and password again instead of doing SSO and login directly. and I see this.isAuthenticated = false in login page. I use below code to get authentication status. Do I need to use anything else for SSO to work?

this.oktaAuth.$authenticationState.subscribe(  
(isAuthenticated: boolean) =\> this.isAuthenticated = isAuthenticated  
);

---

<div class="post-metadata">

**Author:** ![sigama](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/sigama/32/5811_2.png) [@sigama](https://devforum.okta.com/u/sigama)\
**Post date:** [March 3, 2023, 6:21pm UTC](https://devforum.okta.com/t/okta-sso-login-through-angular-spa-application/23525/4 "2023-03-03T18:21:45Z")

</div>

Hi @pmoda, SSO requires shared session cookies within websites. You [can check for an Okta session](https://github.com/okta/okta-auth-js/#sessionexists) and redirect the user to a specific page - [GitHub - okta/okta-auth-js: The official js wrapper around Okta's auth API](https://github.com/okta/okta-auth-js/#tokengetwithredirectoptions) if an active session exists.

---

<div class="post-metadata">

**Author:** ![pmoda](https://avatars.discourse-cdn.com/v4/letter/p/7bcc69/32.png) [@pmoda](https://devforum.okta.com/u/pmoda)\
**Post date:** [March 6, 2023, 6:50am UTC](https://devforum.okta.com/t/okta-sso-login-through-angular-spa-application/23525/5 "2023-03-06T06:50:28Z")

</div>

Thanks sigama. I am seeing following error when trying to check for okta session . From [https://xxxxxxx.okta.com/api/v1/sessions/me](https://xxxxxxx.okta.com/api/v1/sessions/me) I am seeing this error (when putting it in browser) {“errorCode”:“E0000007”,“errorSummary”:“Not found: Resource not found: me (Session)”,“errorLink”:“E0000007”,“errorId”:“oaeG59SHnJyTLC6PJpFkJ8ZSw”,“errorCauses”:} and in F12, I am seeing 404 error.

FYI: I don’t have access to admin for our org okta so I need to request something from that team, please let me know.

---

<div class="post-metadata">

**Author:** ![andrea](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/andrea/32/2172_2.png) [@andrea](https://devforum.okta.com/u/andrea)\
**Post date:** [February 13, 2024, 10:45pm UTC](https://devforum.okta.com/t/okta-sso-login-through-angular-spa-application/23525/6 "2024-02-13T22:45:22Z")

</div>


