Quickstart: Set up sign in for a single-page app using Azure Active Directory B2C

Azure Active Directory B2C (Azure AD B2C) provides cloud identity management to keep your application, business, and customers protected. Azure AD B2C enables your applications to authenticate to social accounts, and enterprise accounts using open standard protocols. In this quickstart, you use a single-page application to sign in using a social identity provider and call an Azure AD B2C protected web API.

If you don't have an Azure subscription, create a free account before you begin.


Run the application

  1. Start the server by running the following commands from the Node.js command prompt:

    npm install && npm update
    npm start

    The server started by server.js displays the port it's listening on:

    Listening on port 6420...
  2. Browse to the URL of the application. For example, http://localhost:6420.

    Single-page application sample app shown in browser

Sign in using your account

  1. Select Sign In to start the user journey.

  2. Azure AD B2C presents a sign-in page for a fictitious company called "Fabrikam" for the sample web application. To sign up using a social identity provider, select the button of the identity provider you want to use.

    Sign In or Sign Up page showing identity provider buttons

    You authenticate (sign in) using your social account credentials and authorize the application to read information from your social account. By granting access, the application can retrieve profile information from the social account such as your name and city.

  3. Finish the sign-in process for the identity provider.

Access a protected API resource

Select Call API to have your display name returned from the web API as a JSON object.

Sample application in browser showing the web API response

The sample single-page application includes an access token in the request to the protected web API resource.

Clean up resources

You can use your Azure AD B2C tenant if you plan to try other Azure AD B2C quickstarts or tutorials. When no longer needed, you can delete your Azure AD B2C tenant.

Next steps

In this quickstart, you used a sample single-page application to:

  • Sign in with a social identity provider
  • Create an Azure AD B2C user account (created automatically at sign-in)
  • Call a web API protected by Azure AD B2C

Get started creating your own Azure AD B2C tenant.