Describe the bug
I use the Azure AD OIDC Code Flow with PKCE. Set everything up with protected routes and everything works fine. But, when i call the getToken()-method i get a "" in return.
The following code in my auth-guard returns true as shown in screenshot further down;
return this.oidcSecurityService.isAuthenticated$.pipe(
map((isAuthorized: boolean) => {
console.log('AuthorizationGuard, canActivate isAuthorized: ' + isAuthorized);
if (!isAuthorized) {
this.router.navigate(['/unauthorized']);
return false;
}
return true;
})
);
Expected behavior
I expected the access-code to be returned so i can use it in my http-requests.
Screenshots
Snapshot from runtime (from method inside oicd-package):

Some snapshots from console after route-changing to show that i actually am authorized.:

Desktop (please complete the following information):
Additional context
Add any other context about the problem here.
hi @kimrunar Are you using the getToken before the authorize request is finished? How do you use this, in an interceptor?
Greetings Damien
No, i use the getToken in another protected component on ng-init. So i first change routes to check if everything is ok. - Which it is based on the output from the interceptor.. Then i go to the route that runs the getToken that oddly fails to retrieve my token.

The chechAuth completes after the getToken is called, which means you call it before the auth process is complete.
Use the authenticated event to check if you are authenticated and then call the getToken().
Pease check the examples and the docs for appropriate usage
https://github.com/damienbod/angular-auth-oidc-client/blob/master/docs/samples.md
Here's 2 more examples:
https://github.com/damienbod/AzureAD-Auth-MyUI-with-MyAPI/tree/master/MySpaAngularUI
Greetings Damien
Ok thank you,
so now i tried your example 'MySpaAngularUI' and its the same result.
Why is auth : false in console when it says i'm logged in/authorized in the app...? Is there something i miss?

Well, after some tinkering, i figured out what was wrong. - typo in my scopes.
Most helpful comment
Well, after some tinkering, i figured out what was wrong. - typo in my scopes.