Quickstart: Sign in and get an access token in an Angular SPA using the auth code flow
Welcome! This probably isn't the page you were expecting. While we work on a fix, this link should take you to the right article:
We apologize for the inconvenience and appreciate your patience while we work to get this resolved.
See How the sample works for an illustration.
This quickstart uses MSAL Angular v2 with the authorization code flow.
- Azure subscription - Create an Azure subscription for free
- Visual Studio Code or another code editor
Step 1: Configure your application in the Azure portal
For the code sample in this quickstart to work, add a Redirect URI of
Your application is configured with these > attributes.
Step 2: Download the project
Run the project with a web server by using Node.js
Step 3: Your app is configured and ready to run
We have configured your project with values of your app's properties.
Step 4: Run the project
Run the project with a web server by using Node.js:
To start the server, run the following commands from within the project directory:
npm install npm start
Select Login to start the sign-in process and then call the Microsoft Graph API.
The first time you sign in, you're prompted to provide your consent to allow the application to access your profile and sign you in. After you're signed in successfully, click the Profile button to display your user information on the page.
How the sample works
The MSAL.js library signs in users and requests the tokens that are used to access an API that's protected by the Microsoft identity platform.
If you have Node.js installed, you can download the latest version by using the Node.js Package Manager (npm):
npm install @azure/msal-browser @azure/msal-angular@2