Open Closed

Getting-ForBidden-while-calling-from-one-service-method-to-another-service-method #8496


User avatar
0
Karunakar created

Provide us with the following info: 🧐 Hint: If you are using the ABP Studio, you can see all the information about your solution from the configuration window, which opens when you right-click on the solution and click on the Solution Configuration button.

  • ABP Framework version: latest
  • UI Type: Angular
  • Database System: EF Core (MySQL)
  • Tiered (for MVC) or Auth Server Separated (for Angular): yes(micro services architecture with separate modules)
  • Exception message and full stack trace: Forbidden
  • Steps to reproduce the issue: While calling the remote api from another api appservice to appservice getting forbidden error.
  • I have a vendor enity with crud operations service in vendormodule and that is having list of addresses this address entity crud operations are in coreaccounting module.
  • after saving the vendor i need to save list of addresses belongs to this vendor while calling the address service saveall method in coreaccouning module getting forbidden error all the configgurations are made correctly.

11 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    HI,

    Try install Volo.Abp.Http.Client.IdentityModel.Web to your project.

    It will try get access_token from current user.

    https://github.com/abpframework/abp/blob/dev/framework/src/Volo.Abp.Http.Client.IdentityModel.Web/Volo/Abp/Http/Client/IdentityModel/Web/HttpContextIdentityModelRemoteServiceHttpClientAuthenticator.cs#L24

  • User Avatar
    0
    Karunakar created

    Hi LiangShiwei,

    In which project I need to install this package Vendor or CoreAccounting? I am calling method from vendor to core accounting. Also we have module and service projects separate, should I need to install in service or module?

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    HI,

    you should add it in the project that sends the request and don't forget add the module dependencies to the Module class

  • User Avatar
    0
    Karunakar created

    added in both module and service projects but getting same error

  • User Avatar
    0
    Karunakar created

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    I see, you are using the client credentials, is the client has the adress permissions ?

    Could you please share the full logs(auth, services) with me? thanks

  • User Avatar
    0
    Karunakar created

    There are not much logs created.. We are logged in as admin user and granted all the permissions to admin

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    because you are using the client credentials, you have to assign permissions to client, not role.

  • User Avatar
    0
    Karunakar created

    Eurekaa.. Success I am able to call the service from another service after giving the permissions to client. Thank you for your support

  • User Avatar
    0
    Karunakar created

    Actually I missed to verify the update there are two methods create and update in my vendor(caller) service both are calling the core accounting service SaveAllAsync method having [HttpPost] attribute. While creating there is no errors am able to call the core accounting service SaveAllAsync method from Vendor, but while updating again getting the Forbidden error.

    Below screens showing calling same service SaveAllAsync in coreaccounting from vendor service create and update methods. From Create method it is success but from update is getting Forbidden

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    I can't see any difference with two methods, you should check the permissions

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