Open Closed

How to create a new user with IdentityService from other microservice #8232


User avatar
0
sefa created
  • ABP Framework version: v8.2.0
  • UI Type: Angular
  • Database System: EF Core (SQL Server, Oracle, MySQL, PostgreSQL, etc..)
  • Tiered (for MVC) or Auth Server Separated (for Angular): yes
  • Exception message and full stack trace: [08:34:23 INF] Executing endpoint 'Volo.Abp.Identity.IdentityUserController.CreateAsync (Volo.Abp.Identity.Pro.HttpApi)' [08:34:23 INF] Route matched with {area = "identity", controller = "User", action = "Create"}. Executing controller action with signature System.Threading.Tasks.Task`1[Volo.Abp.Identity.IdentityUserDto] CreateAsync(Volo.Abp.Identity.IdentityUserCreateDto) on controller Volo.Abp.Identity.IdentityUserController (Volo.Abp.Identity.Pro.HttpApi). [08:34:23 INF] Authorization failed. These requirements were not met: PermissionRequirement: AbpIdentity.Users.Create PermissionRequirement: AbpIdentity.Users [08:34:23 WRN] ---------- RemoteServiceErrorInfo ---------- { "code": "Volo.Authorization:010001", "message": "Authorization failed! Given policy has not granted.", "details": null, "data": {}, "validationErrors": null }

[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, Func3 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.CastleAsyncAbpInterceptorAdapter1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func3 proceed) at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo) at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue1.ProceedAsync() at Volo.Abp.Uow.UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation) at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func3 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.

  • Steps to reproduce the issue:
  • I am creating a new microservice (A). This microservice communicates with other microservices.
  • I want to create a new user from microservice A.
  • According to the "Synchronous Communication Between Microservices in Abp" document, I add IdentityService to microservice A.
  • When I try to create a new user by calling IdentityService via microservice A, I get a 401 error.

5 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    You should use the integration services to communicate in microservices.

    See https://abp.io/docs/8.2/guides/interservice-communication https://abp.io/docs/latest/framework/api-development/integration-services https://abp.io/docs/latest/tutorials/modular-crm/part-06

  • User Avatar
    0
    sefa created

    hi maliming

    Thank you for your quick response. I created IntegrationAppService in IdentityService. But I cannot access this service I created from other microservices.

    Identity.Contracts

    Identity.Application

    Microservice application.csproj

    Microservice application.cs

    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?

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    You can try to add a new IntegrationService in the Identity Pro module instead of IdentityService.
    Similar with IIdentityUserIntegrationService

    Use Identity Pro source code references to solve the problem.


    If the above is complicated, You can consider to using https://abp.io/docs/latest/guides/asynchronous-interservice-communication

  • User Avatar
    0
    sefa created

    Thanks. I solved it using integration service.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Great!

Made with ❤️ on ABP v9.1.0-preview. Updated on December 13, 2024, 06:09