Thanks. I changed the app token lifetime and the problem was solved.
public MerchantAppService(
IMerchantRepository merchantRepository,
IProductGroupAppService productGroupAppService,
...
)
{
_productGroupAppService = productGroupAppService;
...
}
public async Task<MerchantDetailDto> GetDetailAsync(Guid id)
{
MerchantDetailDto merchantDetail = new MerchantDetailDto();
var merchant = await _merchantRepository.GetDetailAsync(id);
merchantDetail.Merchant = ObjectMapper.Map<Merchant, MerchantDto>(merchant);
merchantDetail.ProductGroups = await _productGroupAppService.GetListByMerchantIdAsync(id);
...
}
[08:34:28 INF] Sending HTTP request GET http://192.168.1.105:44516/api/setting-service/product-group/by-merchant-id/c8909caa-775d-f757-aadb-3a1559e60015?api-version=1.0 [08:34:28 INF] Received HTTP response headers after 12.7151ms - 401 [08:34:28 INF] End processing HTTP request after 12.8701ms - 401 [08:34:28 ERR] ---------- RemoteServiceErrorInfo ---------- { "code": "Unauthorized", "message": "Unauthorized", "details": null, "data": null, "validationErrors": null }
[08:34:28 ERR] Unauthorized
[08:34:28 INF] Bearer was not authenticated. Failure message: IDX10223: Lifetime validation failed. The token is expired. ValidTo (UTC): '11/15/2024 8:28:35 AM', Current time (UTC): '11/15/2024 8:34:28 AM'.
[08:34:28 INF] Executing endpoint 'MyProject.SettingService.ProductGroups.ProductGroupController.GetListByMerchantIdAsync (MyProject.SettingService.HttpApi)'
[08:34:28 INF] Route matched with {area = "SettingService", action = "GetListByMerchantId", controller = "ProductGroup"}. Executing controller action with signature System.Threading.Tasks.Task1[System.Collections.Generic.List
1[MyProject.SettingService.ProductGroups.ProductGroupDto]] GetListByMerchantIdAsync(System.Guid) on controller MyProject.SettingService.ProductGroups.ProductGroupController (MyProject.SettingService.HttpApi).
[08:34:28 INF] Skipping the execution of current filter as its not the most effective filter implementing the policy Microsoft.AspNetCore.Mvc.ViewFeatures.IAntiforgeryPolicy
[08:34:28 INF] Authorization failed. These requirements were not met:
PermissionRequirement: SettingService.ProductGroups
[08:34:28 WRN] ---------- RemoteServiceErrorInfo ----------
{
"code": "Volo.Authorization:010001",
"message": "Authorization failed! Given policy has not granted.",
"details": null,
"data": {},
"validationErrors": null
}
[08:34:28 WRN] Exception of type 'Volo.Abp.Authorization.AbpAuthorizationException' was thrown. Volo.Abp.Authorization.AbpAuthorizationException: Exception of type 'Volo.Abp.Authorization.AbpAuthorizationException' was thrown.
When I clear the redis cache, the problem is temporarily solved. A few minutes later, I encounter the same scenario again.
Note: I only have this problem with communication between microservices.
Thanks. I solved it using integration service.
hi maliming
Thank you for your quick response. I created IntegrationAppService in IdentityService. But I cannot access this service I created from other microservices.
Microservice application.csproj
I know I can't access it because I can't create proxies in the identity service. But I still wanted to explain. What should I do now?
[08:34:23 WRN] Exception of type 'Volo.Abp.Authorization.AbpAuthorizationException' was thrown.
Volo.Abp.Authorization.AbpAuthorizationException: Exception of type 'Volo.Abp.Authorization.AbpAuthorizationException' was thrown.
at Microsoft.AspNetCore.Authorization.AbpAuthorizationServiceExtensions.CheckAsync(IAuthorizationService authorizationService, AuthorizationPolicy policy)
at Volo.Abp.Authorization.MethodInvocationAuthorizationService.CheckAsync(MethodInvocationAuthorizationContext context)
at Volo.Abp.Authorization.AuthorizationInterceptor.AuthorizeAsync(IAbpMethodInvocation invocation)
at Volo.Abp.Authorization.AuthorizationInterceptor.InterceptAsync(IAbpMethodInvocation invocation)
at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func
3 proceed)
at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo)
at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue1.ProceedAsync() at Volo.Abp.Auditing.AuditingInterceptor.ProceedByLoggingAsync(IAbpMethodInvocation invocation, AbpAuditingOptions options, IAuditingHelper auditingHelper, IAuditLogScope auditLogScope) at Volo.Abp.Auditing.AuditingInterceptor.InterceptAsync(IAbpMethodInvocation invocation) at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter
1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func3 proceed) at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo) at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue
1.ProceedAsync()
at Volo.Abp.Uow.UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation)
at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func
3 proceed)
at lambda_method1803(Closure, Object)
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.