Base solution for your next web application
Open Closed

How to call API from azure function with authorization token. #10309


User avatar
0
SRTMDEV created

Hello Team,

I would like to create one Auzre Function and want to execute one API from Azure Function. Now once Azure Function job has been finished I want to store data to database by calling API which I is runinng in Azure VM. Now I need your help on right approch. Is it right way to pass authorization token from API server to Azure Function and same token will be use from Azure Function to API server? Any other right approch are welcome.

Thanks, SRTMDEV


7 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    You can get a token as explianed in;

    For Angular version, see https://docs.aspnetzero.com/en/aspnet-core-angular/latest/Features-Angular-Token-Based-Authentication

    For MVC version, see https://docs.aspnetzero.com/en/aspnet-core-mvc/latest/Infrastructure-Core-Mvc-Token-Based-Authentication

    Then, you can call the API using this token as explained in the document.

  • User Avatar
    0
    SRTMDEV created

    In provided solution how can provide credential as you know that Azure Function just execute job without user interface. Is there any solution in which we can create special scope for specific resource and provide client id, secret id etc. We don't want to pass username and password.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @SRTMDEV

    client id and clietn secret is not supported at the moment by default.

  • User Avatar
    0
    SRTMDEV created

    Hello Team,

    Any update on above? We have a scenario where our client app need to communicate with our server app using API. Out of client id and secret, is there any other token we can generate per tenant which case use for client app and with that token we can communicate to our server?

  • User Avatar
    0
    m.aliozkaya created
    Support Team

    Hello @SRTMDEV,

    Regarding authentication in Aspnetzero, the available token for authentication is limited. However, you have the flexibility to customize the TokenAuthController based on your specific requirements and preferences.

    Please let me know if there's anything specific you'd like to achieve or if you need assistance with customizing the controller. I'm here to help!

  • User Avatar
    0
    SRTMDEV created

    Thanks you m.aliozkaya for your response. Currently I am looking for how I can communicate my ANZ web app from externally without Username and Password. I have two type of scenario for external application. In 1st external app who want to access our ANZ app API can use ClientId and ClientSecret to communicate and in 2nd scenario there is our external app which can be access from our app. Tenant user can redirect to our external app and I am thinking some AccessToken kind of send via external URL and can communicate ANZ using that token from our external app. In both case I can auto create ClientId, ClientSecret or AccessToken while generate tenant and can use in such scenario. Any of your idea are really appreciate to achieve such requirement.

  • User Avatar
    0
    m.aliozkaya created
    Support Team

    Hi @SRTMDEV,

    Aspnetzero supports open id protocol, you can use it for other applications to access your app. We do not support the identity server at the moment, but you can activate the open id protocol similar to the steps here.https://docs.aspnetzero.com/en/aspnet-core-angular/latest/Infrastructure-Core-Angular-Identity-Server4-Integration

    In the appsettings.json you can enable it.

    For authentication without username and password you need override TokenAuthController.