Angular quickstart setup, login token not stored but in URL instead

I followed the Angular quick setup guide, it lets me redirect correctly to the Okta’s login in page and log in but the token is then returned inside the URL (http://localhost:4200/implicit/callback#id_token=eyJra…) and oktaAuth.isAuthenticated() returns always false. Any idea of where i might be wrong? Reading the guide i understood that the OktaCallbackComponent should intercept it and store it locally, right?

isAuthenticated is checking the location.hash.

I’m unsure what is missing here, what version of angular are you using? Is there an open source project that we can look at?

Hey @Lamba92. Looks like there might be an issue with the callback URI. Just to verify, can you make sure you’ve attached the OktaCallbackComponent to your router?

const appRoutes: Routes = [
    path: 'implicit/callback',
    component: OktaCallbackComponent

The OktaCallbackComponent calls a function named handleAuthentication, which will parse the tokens from the callback URI, then redirect you back to the original page.

Once redirected, the oktaAuth.isAuthenticated() method should return true, as there is an accessToken and/or idToken stored in browser storage.

If you already have the OktaCallbackComponent setup, there should be a console error in your browser.


I wrote the wrong redirect urls! now it works thanks ^^

1 Like