Open Closed

Dynamic C# API Client Proxies authentication #6047


User avatar
0
igoron761 created

How can I configure authentication options for remote services?

I configure remote service by follow code:

//Create dynamic client proxies context.Services.AddHttpClientProxies( typeof(FeedServiceApplicationContractsModule).Assembly, remoteServiceConfigurationName: "FeedService" );

but could not find solution to configure authentication options.

  • ABP Framework version: v7.4.0
  • UI Type: Angular / MVC / Blazor WASM / Blazor Server
  • Database System: EF Core (SQL Server, Oracle, MySQL, PostgreSQL, etc..) / MongoDB
  • Tiered (for MVC) or Auth Server Separated (for Angular): yes/no
  • Exception message and full stack trace:
  • Steps to reproduce the issue:

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

    Hi,

    May I ask, do you want to use the current user's credentials or the client credentials?

  • User Avatar
    0
    igoron761 created

    it is communication between microservices

    client credentials should be enough but current user also also fine.

    could you describe both options ?

  • User Avatar
    0
    gterdem created
    Support Team Senior .NET Developer

    We've a documentation about communication between microservices: https://docs.abp.io/en/commercial/latest/startup-templates/microservice/synchronous-interservice-communication

    Essentially, you get to choose the authentication flow for this communication. Recommended way is using the client_credentials flow as in the samples. Or, you can use ResourceOwnerPassword flow where you need to define a user and the password to obtain the access token.

  • User Avatar
    0
    igoron761 created

    it help, thank you. but if I have several microservices and want to use different credentials. I added several sections to IdentityClients settings. how can I configure what credentials to use for specific remote service?

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    You can configure IdentityClients for different services

     "IdentityClients": {
        "Default": {
          "GrantType": "client_credentials", 
          "ClientId": "BookStore_OrderService",
          "ClientSecret": "1q2w3e*",
          "Authority": "https://localhost:44322", 
          "Scope": "ProductService"
        },
        "AbpIdentity":{
          "GrantType": "client_credentials", 
          "ClientId": "BookStore_OrderService",
          "ClientSecret": "1q2w3e*",
          "Authority": "https://localhost:44322", 
          "Scope": "IdentitytService"
        }
      }
    
Made with ❤️ on ABP v8.2.0-preview Updated on March 25, 2024, 15:11