- ABP Framework version: v7.3.1
- UI Type: MVC
- Database System: EF Core (SQL Server, Oracle, MySQL, PostgreSQL, etc..)
- Module Template (Separated Deployment & Databases Scenario): yes
Hello,
As I've mentioned here , I call the file management app service, which is implemented on AuthService as if it is a microservice, on my domain service by using remote service call. I use static proxy scripts to achieve that. When I call it, I get an authorization error since we don't have httpContext access on background job. I implement AbpHttpClientIdentityModelWebModule on HttpApi.Host to pass the current token to authorization header (not using the AbpHttpClientIdentityModelModule with client_credentials flow)
Here is the part of my domain service method (ExportAsBaseModelAsync) which uses fileDescriptorAppService:
Here is the error log on HttpApi.Host and AuthServer
How can I send the request behalf of the user with current token? Is there a way to do that magically like ApplicationService methods?
3 Answer(s)
-
0
Hi,
The Background Job means that it has nothing to do with the current request. It is another separate thread.
If you want to use the token of the current user, then you should not call remote services in the background job.
-
0
Is using the client credentials flow suggested if I want to use the remote service in the background job?
-
0
Hi,
Yes, it is, That's what it does in the microservice template.
https://docs.abp.io/en/commercial/latest/startup-templates/microservice/synchronous-interservice-communication#configuring-auto-discovery-endpoint