How to get an Azure AD access token programmatically from a MAUI application, to access a secured Web API in .NET6?
I have a secured Web API written in .NET 6 using minimal API which is hosted in a Linux App Service plan in Azure.
I setup an Azure AD app registration, and I can successfully get an access token using Postman, and authenticating with my Azure credentials.
To get that token, in Postman, I use:
Authorization URL: https://login.microsoftonline.com/my-tentant-id/oauth2/v2.0/authorize
Access Token URL: https://login.microsoftonline.com/my-tentant-id/oauth2/v2.0/token
Client ID: my-client-id
Client Secret: my-client secret
Scope: api://my-client-id/access_as_user
Then, I use that token to call the secured Web API and works well.
If I use that same token, when I call the Web API from my MAUI application, it does work as well.
My problem, is I haven't been able to find the correct documentation, to get the access token programmatically, from the MAUI app.
Several examples seem to work, but in .NET Core applications, Web Applications, etc. but nothing I have tried, has worked from the MAUI app.
Any help will be appreciated.
Thanks.