Open Closed

ABP RemoteService Client Proxy not passing bearer token to another appservice with dynamic client proxy #9026


User avatar
0
richardf created
  • Template: app
  • Created ABP Studio Version: 0.8.2
  • Current ABP Studio Version: 0.9.25
  • Tiered: Yes
  • UI Framework: angular
  • Theme: leptonx
  • Theme Style: system
  • Progressive Web App: Yes
  • Database Provider: ef
  • Database Management System: mysql
  • Separate Tenant Schema: Yes
  • Mobile Framework: none
  • Public Website: No
  • Optional Modules:
    • LanguageManagement
    • AuditLogging
    • SaaS
    • OpenIddictAdmin
  • Exception message and full stack trace:

  • Steps to reproduce the issue: Need to call another app service endpoint.

From patient appservice call method in datamaintenance appservice.

so in my Patient Application module including service endpoint

protected IMedicalAidAppService MedicalAidHttpClient => LazyServiceProvider.LazyGetRequiredService<IMedicalAidAppService>();

this is defined in my datamaintenance module which the httpclient module exposes as :

public class DataMaintenanceHttpApiClientModule : AbpModule
{
    public override void ConfigureServices(ServiceConfigurationContext context)
    {
        context.Services.AddHttpClientProxies(
            typeof(DataMaintenanceApplicationContractsModule).Assembly,
            DataMaintenanceRemoteServiceConsts.RemoteServiceName
        );

In my patient app service

[DependsOn(
    typeof(PatientDomainModule),
    typeof(PatientApplicationContractsModule),
    typeof(AbpDddApplicationModule),
    typeof(AbpAutoMapperModule),
    typeof(DataMaintenanceHttpApiClientModule),
    typeof(AbpHttpClientIdentityModelModule)
    )]

and calling :

public async Task<List<DefaultCodedNameValue<string>>> GetMedicalAidsAsync()
 {
     return await MedicalAidHttpClient.GetMedicalAidsAsync().ConfigureAwait(false);
 }

this works if no [Authorize] header in data maintenance appservice otherwise getting unauthorized.

Appsettings: in patient.http:

 "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft": "Warning",
      "Microsoft.Hosting.Lifetime": "Information"
    }
  },
  "RemoteServices": {
    "DataMaintenance": {
      "BaseUrl": "https://localhost:55344",
      "UseCurrentAccessToken": "true"
    }
  }
}

if I authenticate to patient it works and in datamaintenance it works, but from patient to datamaintenance unauthorized.

So the auth token has the correct bearer in patient but not being passed through.

Pls can you assist


2 Answer(s)
  • User Avatar
    0
    richardf created

    Maybe just guide me to the correct article?

    I referred tothis one but no luck:

    https://abp.io/support/questions/140/Using-Dynamic-HttpApiClient-resulting-in-401-Unauthorized

    referring to this, also tired it:

    https://abp.io/docs/latest/Samples/Microservice-Demo#passing-the-access-token-1

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Can you share a template project to reproduce?

    liming.ma@volosoft.com Thanks

Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
Do you need assistance from an ABP expert?
Schedule a Meeting
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v9.3.0-preview. Updated on April 16, 2025, 12:13