Coder Social home page Coder Social logo

Comments (4)

santosmken avatar santosmken commented on August 14, 2024 1

Hi @casha17 @Sonik20, what I did here is that I added the following code from my providers array .

{ provide: APP_INITIALIZER, useFactory: (someService: someServiceName) => () => someServiceName.initializeAuth(), deps: [someServiceName], multi: true }

It will be your top level checking before the app.component gets initialize and it will force the user to get redirected to your IDp to sign-in. After that, you can make a guard and add it within the module you want to protect. Basically what the guard will do is it will validate if your idToken & accessToken from OAuthService are valid, otherwise you can call initCodeFlow or other similar method to login.

from sample-angular-oauth2-oidc-with-auth-guards.

jeroenheijmans avatar jeroenheijmans commented on August 14, 2024

Many ways to go about that, including:

Hope that helps!

(Closing the issue, as I hope this issue -even closed- plus the comments at that last link are enough guidance for future visitors...)

from sample-angular-oauth2-oidc-with-auth-guards.

Sonik20 avatar Sonik20 commented on August 14, 2024

@jeroenheijmans Tried this but not working for me.

It only redirects to server when silent refresh timeout error occurs, i want when the application boots up for the first time it should ask for login.

from sample-angular-oauth2-oidc-with-auth-guards.

jeroenheijmans avatar jeroenheijmans commented on August 14, 2024

Hey @Sonik20 sorry to hear you're still having an issue with your setup! I'm just one person here in this repository though, so not really bandwidth to help folks out with their individual setups, beyond general guidance. I recommend asking a question e.g. on Stack Overflow or Reddit or some such, adding a reproducible scenario and telling them what the obstacle is. Many more people there to reliably help you out!

from sample-angular-oauth2-oidc-with-auth-guards.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.