Frustrated with Bad Tutorials

I am building an Angular SPA and I need the application to automatically detect whether the user has already logged-in, redirect the user to the established Okta login page if they aren’t already logged in, and then once they have logged in, redirect them back to the SPA.

I have already tried the following tutorials from the Okta website at

Neither of these tutorials really demonstrate the functionality that I need. They are also buggy and don’t really work as written, but that’s a separate issue.

Can anyone point me to a tutorial-like resource that shows how to implement this? Bonus points if it’s written for the current version of whatever library it uses.

1 Like

Hi @chrisroberton,

You can use the following link to setup an angular app with okta - https://developer.okta.com/docs/guides/sign-into-spa/angular/before-you-begin/

The first link you posted will be removed soon, as that guide has been deprecated.
Also, you can try a working angular sample here - https://github.com/okta/samples-js-angular

Hope this helps.

I have been struggling with this one for a couple of days. Some feedback for you guys, in the hopes that it makes it down to whoever writes these things

  1. None of the little code snippets tell you what file to put the code in. You have to decipher it based on the class, and its not very intuitive. Heaven help you if you are starting from scratch because you have nothing to match it with.
  2. When I implement the tutorial, it doesn’t function as described. The login button that it tells you to build doesn’t appear on my page. Instead, I am just automatically forwarded to the login page when I hit my SPA.
  3. The tutorial is incomplete, because it doesn’t tell you how to make the route to your application work after the login. As written, it just loops infinitely - redirect to my page - redirect to Okta page - repeat forever.
3 Likes

Hi @chrisroberton, not sure if you already had this addressed but our angular samples are a really good resource for these issues you have mentioned. Do take a look and see if it helps: https://github.com/okta/samples-js-angular.

Hi @chrisroberton :slight_smile:
I’m trying to achieve pretty much the same thing as you…
We have:

  • Angular App
  • hosted Okta widget
  • enabled self registration in Okta
  • enabled social logins - facebook and google
  • we want to check for active session if the user is already logged in in the underlying Okta instance

Issues:

  1. How to check for active session with Okta from Angular App
  2. How to redirect the user AFTER facebook/google login to the Angular App AND still have logged in user with proper access token in the Angular app
  3. Where to intercept both self registered and social IdP registered users in single point, so I can properly create those users in my backend API

Any useful tutorials and/or hints are welcome…

Best regards,
Pirin