I am trying to connect from my angular app to Identity server but I am getting "wanted to read clientId_authzData but nothing was found"
I am using angular11 and "angular-auth-oidc-client": "^11.5.1",
I followed the steps from below https://github.com/damienbod/angular-auth-oidc-client/blob/main/docs/quickstart.md
component.hml file
<button (click)="login()">Login</button>
<button (click)="callapi()">Call API</button>
<button (click)="logout()">Logout</button>
component.ts file
ngOnInit(): void {
this.oidcSecurityService.checkAuth().subscribe((auth) => console.log('is authenticated', auth));
}
login() {
this.oidcSecurityService.authorize();
this.oidcSecurityService.userData$.subscribe((usr) => {
console.log("User -->", usr);
})
console.log("Token --> " + this.oidcSecurityService.getIdToken());
}
callapi(){
}
logout() {
this.oidcSecurityService.logoff();
}
app.Module.ts
export function configureAuth(oidcConfigService: OidcConfigService) {
return () =>
oidcConfigService.withConfig({
stsServer: 'https://localhost:5001',
redirectUrl: window.location.origin,
postLogoutRedirectUri: window.location.origin,
clientId: 'clientangular',
scope: 'openid profile api1 roles offline_access',
responseType: 'code',
//silentRenew: false,
//silentRenewUrl: `${window.location.origin}/silent-renew.html`,
logLevel: LogLevel.Debug,
});
}
Identity server client setup
new Client
{
ClientId = "clientangular",
ClientName = "Unity Angular Client",
AllowedGrantTypes = GrantTypes.Code,
RequireClientSecret = false,
AllowedScopes = new List<string>
{
IdentityServerConstants.StandardScopes.OpenId,
IdentityServerConstants.StandardScopes.Profile,
"api1",
"roles"
},
RedirectUris = new List<string> {"http://localhost:4200"},
PostLogoutRedirectUris = new List<string> {"http://localhost:4200"},
AllowedCorsOrigins = new List<string> { "http://localhost:4200"},
RequireConsent= false,
RequirePkce = true,
//AlwaysIncludeUserClaimsInIdToken = true,
AllowAccessTokensViaBrowser = true,
AllowOfflineAccess = true
}
- While clicking the login button it is redirecting to the identity server
- After enter the user id and password its is redirect back to the angular page
- I can see the authenticated value as false and can't get token also
I have attached the console log. Kindly help me on this
