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.

Hi, I went through the sample and got it working, however in my organization application, we are using custom callback component, there I still see this issue where okta access token is undefined when I just redirected from Okta login page.

Do you have any examples using custom callback component or may be where the issue is.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.