Okta-angular getAccesstoken result is undefined

Hi,

I try to create a login process with Okta, I follow this to do it.

I follow each step but when I want to have the access token I receive undefined.
`

       /**
       * Init of component
       */
      async ngOnInit() {
        // reset login status
        // this.authenticationService.logout();
        const accessToken = await this.oktaAuth.getAccessToken();
        console.log(accessToken); // => undefined
      }

`

Someone can help to fix this ?

Thx

Hi @julien.hillard

The accessToken is most likely undefined because you’re not in an authenticated state.

Without seeing how your login logic, its hard to diagnose what could be causing this. I’d strongly suggest taking a look at the Okta Angular Samples repository, as it is a fully-functional application using the quick-start sample you referenced above.