- ABP Framework version: v5.3.3
- UI type: MVC
- DB provider: EF Core
- Module Template (Separated Deployment & Databases Scenario): yes
Hello all,
I've wanted to use IIdentityRoleAppService to add roles, get roles etc. in my app service but somehow I have not been able to use it. I've examined the https://support.abp.io/QA/Questions/2785/Consume-external-REST-API-to-get-data issue to see how to use different application services in the app service. I've followed three steps that mentioned. I've ended up with "unauthorized error" even though I've had the right permissions. Here are the steps to reproduce the issue:
- Create a new solution by using the command
abp new TestAppForRoleAppService -t module-pro --add-to-solution-file --output-folder C:\Users\TestAppForRoleAppService --version 5.3.3
- Create the db and seed the users
- Insert the
Volo.Abp.Identity.Pro.Application.Contracts 5.3.3
package in TestAppForRoleAppService.Application.Contracts to get the interfaces. - Insert the
Volo.Abp.Identity.Pro.HttpApi.Client
package in TestAppForRoleAppService.HttpApi.Host and insert it in module dependencies - Remote service configuration on TestAppForRoleAppService.HttpApi.Host . (It's base url is https://localhost:44388/ which is the identity server url since the related services are in identity server)
- Use the IIdentityRoleAppServices to get all roles in the sample services
- Run the projects : TestAppForRoleAppService.HttpApiHost, TestAppForRoleAppService.IdentityServer and TestAppForRoleAppService.Web.Host
- Call it from the host by using the swagger and get the unauthorized error
- Check the identity server logs and see the error which is caused for missing privilege, but I have the right permission to get the roles.
Am I missing something to use the app service in another app service or is it kind a bug for the module template?
Thanks. Kind Regards
5 Answer(s)
-
0
Hi,
You can check this: https://github.com/abpframework/abp/blob/rel-5.2/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.HttpApi.Client.ConsoleTestApp/ClientDemoService.cs#L39
https://github.com/abpframework/abp/blob/rel-5.2/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.HttpApi.Client.ConsoleTestApp/appsettings.json#L10
-
0
Yes, I know how to use this in another client, but I want to use this app service with current user authorization in another web application. I don't want to configure the username or password on configuration file. How to use this app service without giving some information on configuration file? I prefer to do that with Dynamic C# API Client Proxies or is there any different options for that purpose?
-
0
Hi,
You can install the
Volo.Abp.Http.Client.IdentityModel.Web
package to your project.It will try to get
access_token
from the current HTTPContext and add it to request headers.https://github.com/abpframework/abp/blob/dev/framework/src/Volo.Abp.Http.Client.IdentityModel.Web/Volo/Abp/Http/Client/IdentityModel/Web/HttpContextIdentityModelRemoteServiceHttpClientAuthenticator.cs
-
0
Is using this package okay on HttpApi.Host application?
-
0
Hi,
Yes