[AZURE.TIP] Try the preview of our new developer portal that will help you get up and running with Azure Active Directory in just a few minutes! The developer portal will walk you through the process of registering an app and integrating Azure AD into your code. When you’re finished, you will have a simple application that can authenticate users in your tenant and a backend that can accept tokens and perform validation.
For more information about how the protocols work in this scenario and other scenarios, see Authentication Scenarios for Azure AD.
Getting started is simple! To run this sample you will need: - Visual Studio 2013 - An Internet connection - An Azure Active Directory (Azure AD) tenant. For more information on how to get an Azure AD tenant, please see How to get an Azure AD tenant - A user account in your Azure AD tenant. This sample will not work with a Microsoft account, so if you signed in to the Azure portal with a Microsoft account and have never created a user account in your directory before, you need to do that now.
From your shell or command line:
https://localhost:44302/. Click on Create to create the application.
By default, applications provisioned in Azure AD are not enabled to use the OAuth2 implicit grant. In order to run this sample, you need to explicitly opt in.
oauth2AllowImplicitFlowproperty. You will find that it is set to
false; change it to
trueand save the file.
ida:Tenantand replace the value with your AAD tenant name.
ida:Audienceand replace the value with the Client ID from the Azure portal.
App/Scripts/App.jsand locate the line
window.config = ....
tenantwith your AAD tenant name.
clientIdwith the Client ID from the Azure portal.
Clean the solution, rebuild the solution, and run it.
You can trigger the sign in experience by either clicking on the sign in link on the top right corner, or by clicking directly on the Todo List tab. Explore the sample by signing in, adding items to the To Do list, removing the user account, and starting again.
The key files containing authentication logic are the following:
App.js - Provides the app configuration values used by ADAL for driving protocol interactions with AAD, indicates which routes should not be accessed without previous authentication, issues login and logout requests to Azure AD, handles both successful and failed authentication callbacks from Azure AD, and displays information about the user received in the id_token.
index.html - contains a reference to adal.js.
todoListCtrl.js- shows how to take advantage of the acquireToken() method in ADAL to get a token for accessing a resource.
userDataCtrl.js - shows how to extract user information from the cached id_token.