Get up and running in minutes

Getting Started: Web

The following steps allow you to quickly sign in users to your application using their work or school accounts.

1. Register an app to get a client ID

Register your app to get a client ID and access a personalized version of these instructions. If you already have a client ID for an app with the implicit flow enabled you can skip to the next step.

Register your app

2. Set up the SDK

Copy and paste the following snippet of code into the <head> tag of your HTML file. Then set the value of the clientId and redirectUri variables to your application's corresponding values.


3. Add a button to sign in

Copy and paste the following snippet of code directly into the <body> of your HTML file.


4. Try it out

Load the resulting page/HTML using your HTTP server of choice (in this example we used node.js and http-server). Then click the button to launch a popup that will authenticate the user. After completing authentication, the SDK will provide your application with information about the user who authenticated based on the contents of the token via the getCachedUser method (see “showWelcomeMessage” above) and write the token to the console.


In order to test your application, you will need at least one work account (such as an Office 365 Subscription or Azure Active Directory user account). Learn how to create a work account.


At this point the token has not been validated.  The token must be validated before you can use it to access services or data that you control.

Next Steps

Call your application’s backend service/API to validate the token and authenticate users to your backend service. Learn how to create a backend service