Angular app using @okta/okta-angular SDK - OktaAuthService getAccessToken() getting null first time

Hi Everyone,

I downloaded angular + Okta example from here and NodeJs example from here
And ran both client and server, I am able to login using my okta developer account. I can able to navigate to message route, getting right information.
But I need access token immediately after login success. So I modified app.component.ts(, added below code in ngOnInit() to check if access token available or not. I got null. If I refresh page, then I see access token in browser console.

const accessToken = await this.oktaAuth.getAccessToken();
console.log(" access token ", accessToken);

Am I doing anything wrong here, Okta access token not available for immediate use ? I have requirement in my application that once user successfully logged in, need to make a API call with token, to verify if token is valid or not and to get user information to show in UI on home page.

Please let me know if you need more information.

Hi @bdemers

Can you please look into this ?

Hey @janakiram.gollapudi

I’ve passed this on to @jmelberg, he will have more info on this library than I do

Thanks @bdemers. You guys are awesome :).