How to Register Xamarin.Forms App with Azure Active Directory and Dynamics 365

Dominic Jarvis, 21 September 2017

Registering your app with Azure Active Directory can be incredibly useful for authenticating with services such as Microsoft Dynamics 365. A registered app can request an authentication token with which they can access the Dynamics CRM web API – given they have the correct permissions.

The process for registering your custom application against Azure Active Directory is very straightforward.
1.    Login to your organization at portal.azure.com.
2.    Navigate to Azure Active Directory.

image

3.    Make sure the domain that you want to register the app against is selected.
4.    Navigate to App registrations.

image

5.    Select Add – We’ll come back to this page later also.

image

6.    Fill out the create form with your app’s details.
a.    The redirect URI must be app unique on your selected domain.

image

7.    Clicking create will redirect you to the App summary.

image

8.    Take note of the Application ID. You will use this in your application as the client id when you authenticate with an Active Directory Authentication Library.
9.    There’s one piece of information left to gather, and that’s the Authentication URL/Endpoint. Back in the app dashboard (step 5) there is an Endpoint button at the top of the screen – click that and you will be directed to the available endpoints for your application to use. The endpoint you want to copy is the OAuth 2.0 Authorization Endpoint. Use this and the Application Id to update your code.
10.    That’s it! Your app is now registered with Azure Active Directory. If you want to use the app to integrate with CRM however, there is one more step. In the API Access section in the settings panel, navigate to Required permissions.

image

image

From there, add a permission for Microsoft Dynamics CRM Online. Once this is done, you can use your app to interact with the Dynamics CRM Web API.

A Bit Extra

For hep building an authentication class, and a simple wrapper to interact with the Microsoft Dynamics CRM and Dynamics 365 web API, a tutorial can be found here:

https://blogs.msdn.microsoft.com/crminthefield/2015/07/22/dynamics-crm-developers-build-your-own-mobile-apps-for-windows-ios-and-android-part-5/