简体   繁体   中英

Azure AD v2.0 using the token for MobileApp authentication

I got a Xamarin Form 2.4 project that user Azure AD v2.0 endpoint for authentication. The login part from Xamarin work well. But I can find the correct way to use the received token pass it to the Azure MobilApp to consume some data? For now the login occurs in the Xamarin Project like:

ar = await App.PCA.AcquireTokenAsync(App.Scopes, App.UiParent);

Then I can use ar.AccessToken to call Graph v1.0 to get some user info. How can I do the same for Azure AppService?

I read this: https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-v2-devquickstarts-webapp-webapi-dotnet

But I think this is more for website project in the Azure portal that authenticated on v2.0 Endpoint. In my case the user is already authenticated. I think I need to configure Authentication in my AzurePortal->AppService->Authentication/Authorization->AD Provider->Advanced. But I do not know what to put in IssuerURL and AllowedTokenAudience VS the information in my app.dev.mocrosoft.com (AD v2.0 endpoint)... Then I can set the Authentication of my AppService to On and set Action take when the request is not authenticated to: Login with Azure AD??

I was thinking: 1- Log with AcquireTokenAsync to Azure AD 2.0 portal 2- Use the token to "Login" to my AppService or use it in the Request header when calling service in my AppService 3- Consume data/service

Any suggestion? Thanks,

The Azure AD v2.0 endpoint is only capable of getting tokens for the Microsoft Graph at this point in time, so it likely isn't what you want to use unless you want the Azure Mobile App is attempting to call the Graph.

If you do find you need to call a different API, the library you've used (MSAL) will also need to be changed to ( ADAL .NET ), and you will need to reregister your app on the Azure portal .

If your goal is to programmatically deploy Azure App Services deployments, then I recommend using the Azure Resource Manager which is the service to manage the various Azure resources. To do this, you may need to change your auth model to the Azure AD v1.0 endpoint .

I'll also drop a link to Azure App Services that may help if I misinterpreted your question.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM