damienbod / angular-auth-oidc-client

npm package for OpenID Connect, OAuth Code Flow with PKCE, Refresh tokens, Implicit Flow
https://www.npmjs.com/package/angular-auth-oidc-client
MIT License
1.11k stars 418 forks source link

[Question]: Authorize - not getting called second time - multiple config #1909

Open IC014065 opened 2 months ago

IC014065 commented 2 months ago

What Version of the library are you using? ... angular 15 , angular-auth-oidc-client - "version": "15.0.2"

Question We have two configs with different scopes. One for AuthN and another for AuthZ. First time whene we call the below code it works for the first time. We call getAccessToken with configId and it calls authorize endpoint and then token and returns the token.

constructor( private oidcSecurityService: OidcSecurityService, @Inject(windowToken) private window: Window ) { this.isAuthenticated$.subscribe(() => { oidcSecurityService .getAccessToken('Authentication') .pipe(take(1)) .subscribe((accessToken) => { this.accessToken = accessToken; }); });

But when we call getAccessToken for the second time, it neither calls authorize or nor token endpoint.

getUserAuthorizationAccessToken(): void { this.isAuthenticated$.subscribe(() => { this.oidcSecurityService .getAccessToken('userAuthorization') .pipe(take(1)) .subscribe((userAuthorizationToken) => { console.log('userAuthorizationToken', userAuthorizationToken); this.userAuthorizationToken = userAuthorizationToken; }); }); }

We even tried the checkAuthMultiple() to explicitly authorize and also this.oidcSecurityService.authorize('userAuthorization');. But its not calling authorize endpoint or token and hence no token received second time.

Any help would be much appreciated..!

Thanks,