We have a custom API implementation so without packages of ABP. We created the clientcredentials and we can get data. But on the API the TenantId is not filled so the filtering is not correct now. What should we add to the request to fill the TenantId in the filtering?
I can add it as request parameter and set the tenantId with CurrentTenant.Change(), but there must be a better way. I also tried to add the TenantId as Claim in the Client settings, but that didn't work.
13 Answer(s)
-
0
hi rick
Can you share some code or more details?
We generated the client from the REST API by swagger. This is a C#.NET client of the gateway in the Microservice solution.
This code will not help to solve this. I have to know how we can set the TenantId on the client so it will automaticly filter in the API. Of can we add a setting in the client credential section in the portal?
We can do a Teams call so I can share my screen and you can help me?!
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
hi
There are many ways to set the requested tenant. Please note that
CurrentUserTenantResolveContributorshould always be the first contributor for the security.https://docs.abp.io/en/abp/latest/Multi-Tenancy#default-tenant-resolvers
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
I was just trying to get that TenantId in our ProductService. We are running on a NGINX server so I want to try another key then “__tenantId”.
Our product service solution looks like this (Microservice):
- In the IBP.ProductService.HttpAPI I added this in the ‘ProductServiceHttpApiModule’:

- I also added the CustomTenantResolver:

- When I call the API, I got this error:

- I filled the tenantId in the querystring and in the requestHeader, but both are not used/found. See data:

Questions
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) - In the IBP.ProductService.HttpAPI I added this in the ‘ProductServiceHttpApiModule’:
-
0Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
-
0Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
-
0
Can we do a Teams call to check this together instead of these tickets? Please send me an email to get in touch.
I shared my logging above and there is no other logging about tenantId or name.
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
Hi rick,
please keep the conversation here.
That's okay for me but my problem is not getting solved. Most of the times it helps to share a screen :).
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
Hi,
ABP Applications uses a Middlewre to determine the tenant.
This middleware uses different contributor for trying to find tenant id by given order. When it finds a tenant id, the rest of contributors won't be executed.
CurrentUserTenantResolveContributor> This should always be the first contributor for the security.QueryStringTenantResolveContributorFormTenantResolveContributorRouteTenantResolveContributorHeaderTenantResolveContributorCookieTenantResolveContributor
If the
CurrentUserTenantResolveContributorreturns the tenantId, then theQueryStringTenantResolveContributorwill not be executed.This contributors are checkin the parameter that defined in the
AbpAspNetCoreMultiTenancyOptionsfor the tenant id.You can change it by configuring it as @maliming defined before.
services.Configure<AbpAspNetCoreMultiTenancyOptions>(options => { options.TenantKey = "MyTenantKey"; });The whole tenant resolving works as defined in the documentation https://docs.abp.io/en/abp/latest/Multi-Tenancy#default-tenant-resolvers
How you achieve your problem;
- You may change the order of resolvers. As I understand, you want to make some changes for other tenant that the user does not related.
- You may add your custom tenant resolver. https://docs.abp.io/en/abp/latest/Multi-Tenancy#custom-tenant-resolvers
If you want to make your custom tenant resolver the first executed one, don't forget the change resolver orders.
Regards.
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)



