Base solution for your next web application
Open Closed

Calling Web API (App Service) remotely #3850


User avatar
0
sparkyjr created

Hi,

I need to call a Web API (App Service) from PowerApps. Problem is, I cannot pass the authentication token in the request header. PowerApps uses the Authorization request header key to pass their own token. How can I pass my authentication key? Also, is there any other way to fetch records of specific tenant if I can't pass my token into Authorization key?

Thanks in advance!

Regards, SparkyJr


8 Answer(s)
  • User Avatar
    0
    alper created
    Support Team

    hi,

    This question is more like related with PowerApps. You have to find out how to add request headers to powerapps http requests. then add Authorization header to DefaultRequestHeaders.

    Try to ask the question here <a class="postlink" href="https://community.powerapps.com/t5/forums/searchpage/tab/message?filter=location&q=authentication+header&location=category%3APowerApps1&collapse_discussion=true">https://community.powerapps.com/t5/foru ... ssion=true</a>

  • User Avatar
    0
    sparkyjr created

    Hello Alper,

    Thanks for your reply!

    As I said in my original post:

    Problem is, I cannot pass the authentication token in the request header. PowerApps uses the Authorization request header key to pass their own token.

    It's not possible to add Authorization key in the request header. That's the problem! Is there any way I can fetch data of specific tenant, if I have Tenancy Name with me?

    Thanks and regards, SparkyJr

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @sparkyjr,

    As far as I know, it is not possible to send auth token with a different header but you can check ASP.NET Identity's documentation to see if it is possible or not.

    If your method is not authorized, then you can send tenant's Id in the request header with "Abp.TenantId" parameter. Then, data will be filtered for that tenant.

    Thanks.

  • User Avatar
    0
    sparkyjr created

    Thanks for your reply ismcagdas!

    Could you please give me a working example of a complete request (with request header and body)? Because I tried, and (passing Abp.TenantId in the request header or request body or request query string) it is not working for me. My method is not authorized.

    Thanks and regards, SparkyJr

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @sparkyjr,

    Which version of ABP do you use in your project ? Maybe your version does not have this feature.

  • User Avatar
    0
    sparkyjr created

    Hello ismcagdas,

    From package.config, the ABP version seems to be 0.8.3.0. Does that help?

    Thanks and regards, SparkyJr

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @sparkyjr,

    Your version is old and this feature is not in that version. You can upgrade ABP or you can apply changes related to getting TenantId from request header.

    I couldn't decide which one is easier :).

    You can check the related code for getting tenantId from request header in below links: <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/blob/master/src/Abp.Web/Web/MultiTenancy/HttpHeaderTenantResolveContributor.cs">https://github.com/aspnetboilerplate/as ... ributor.cs</a> <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/blob/master/src/Abp/MultiTenancy/TenantResolver.cs">https://github.com/aspnetboilerplate/as ... esolver.cs</a> <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/blob/master/src/Abp/Runtime/Session/ClaimsAbpSession.cs">https://github.com/aspnetboilerplate/as ... Session.cs</a>

  • User Avatar
    0
    sparkyjr created

    Hi ismcagdas,

    Thank you for your help!

    I will surely have a look at the code, or will upgrade to the latest ABP version (if that's easier). Hopefully, that will help me fix my problem.

    Regards, SparkyJr