abp icon indicating copy to clipboard operation
abp copied to clipboard

After login,Using remote services Volo.Abp.Identity.HttpApi.Client , IdentityService.Host throw AuthenticationScheme: Bearer was not authenticated.

Open thk-liu opened this issue 7 years ago • 0 comments

In my method [Authorize(IdentityPermissions.Users.Create)] is oK。 When i Call await _identityUserAppService.CreateAsync(userCreateDto);
Server Log Tips: 2019-08-20 17:38:11.036 +08:00 [INF] Sending HTTP request POST "http://localhost:63568/api/identity/users?api-version=1.0" 2019-08-20 17:38:11.085 +08:00 [INF] Received HTTP response after 49.8635ms - "Unauthorized" 2019-08-20 17:38:11.086 +08:00 [INF] End processing HTTP request after 50.6633ms - "Unauthorized" 2019-08-20 17:38:11.258 +08:00 [ERR] ---------- RemoteServiceErrorInfo ---------- 2019-08-20 17:38:11.259 +08:00 [ERR] { "code": null, "message": "An internal error occurred during your request!", "details": null, "validationErrors": null } 2019-08-20 17:38:11.259 +08:00 [ERR] Authorization failed! Given policy has not granted: AbpIdentity.Users.Create and IdentityService.Host Server Log Tips: 2019-08-20 18:19:28.173 +08:00 [DBG] AuthenticationScheme: Bearer was not authenticated. 2019-08-20 18:19:31.268 +08:00 [WRN] Authorization failed! Given policy has not granted: AbpIdentity.Users.Create Volo.Abp.Authorization.AbpAuthorizationException: Authorization failed! Given policy has not granted: AbpIdentity.Users.Create

IdentityServiceHostModule configuration: context.Services.AddAuthentication("Bearer") .AddIdentityServerAuthentication(options => { options.Authority = configuration["AuthServer:Authority"]; options.ApiName = configuration["AuthServer:ApiName"]; options.RequireHttpsMetadata = false; //TODO: Should create an extension method for that (may require to create a new ABP package depending on the IdentityServer4.AccessTokenValidation) options.InboundJwtClaimTypeMap["sub"] = AbpClaimTypes.UserId; options.InboundJwtClaimTypeMap["role"] = AbpClaimTypes.Role; options.InboundJwtClaimTypeMap["email"] = AbpClaimTypes.Email; options.InboundJwtClaimTypeMap["email_verified"] = AbpClaimTypes.EmailVerified; options.InboundJwtClaimTypeMap["phone_number"] = AbpClaimTypes.PhoneNumber; options.InboundJwtClaimTypeMap["phone_number_verified"] = AbpClaimTypes.PhoneNumberVerified; options.InboundJwtClaimTypeMap["name"] = AbpClaimTypes.UserName; });

How to Pass Identity?

thk-liu avatar Aug 20 '19 10:08 thk-liu