question

CarloBrunengo-8634 avatar image
0 Votes"
CarloBrunengo-8634 asked ·

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

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-active-directoryazure-webapps
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

MarileeTurscak avatar image
0 Votes"
MarileeTurscak answered ·

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.


·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.