Consume a web ASP.NET Core App api with Azure AD authentication from a console application

Carlo Brunengo 1 Reputation point
2020-01-03T17:02:31.193+00:00

Hi,
I published a Web ASP.NET Core App with Azure AD authentication successully on our Azure subscription.
The business logic of this web app is developed as api route, with json objects as input and output parameters.

I would like to expose this api to external applications (i.e. console application running outside the Azure subscription, calling a get/post httpclient) but I'm not able to set the correct authentication. Any calls to the web app api url return the html Azure sign-in page.

If I set a correct cookie (".AspNetCore.AzureADCookie") on the httpclient call, it works well, but the cookie expires after 1 hour.
How can I generate this cookie?
Otherwise, how can I authenticate the console application to Azure AD to successfully call web app api?

Thanks a lot,
Carlo

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
7,166 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
20,111 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Marilee Turscak-MSFT 35,616 Reputation points Microsoft Employee
    2020-01-03T22:42:41.167+00:00

    Check out the documentation on Configurable Token Lifetimes. You can set the default to 1 day, or use a refresh token to avoid that problem.

    You can also try setting UseTokenLifetime = false if you don't want it to expire at all.

    0 comments No comments