Configure your App Service app to use Facebook login

This article shows how to configure Azure App Service to use Facebook as an authentication provider.

To complete the procedure in this article, you need a Facebook account that has a verified email address and a mobile phone number. To create a new Facebook account, go to facebook.com.

Register your application with Facebook

  1. Go to the Facebook Developers website and sign in with your Facebook account credentials.

    If you don't have a Facebook for Developers account, select Get Started and follow the registration steps.

  2. Select My Apps > Add New App.

  3. In Display Name field:

    1. Type a unique name for your app.
    2. Provide your Contact Email.
    3. Select Create App ID.
    4. Complete the security check.

    The developer dashboard for your new Facebook app opens.

  4. Select Dashboard > Facebook Login > Set up > Web.

  5. In the left navigation under Facebook Login, select Settings.

  6. In the Valid OAuth redirect URIs field, enter https://<app-name>.azurewebsites.net/.auth/login/facebook/callback. Remember to replace <app-name> with the name of your Azure App Service app.

  7. Select Save Changes.

  8. In the left pane, select Settings > Basic.

  9. In the App Secret field, select Show. Copy the values of App ID and App Secret. You use them later to configure your App Service app in Azure.

    Important

    The app secret is an important security credential. Do not share this secret with anyone or distribute it within a client application.

  10. The Facebook account that you used to register the application is an administrator of the app. At this point, only administrators can sign in to this application.

    To authenticate other Facebook accounts, select App Review and enable Make <your-app-name> public to enable the general public to access the app by using Facebook authentication.

Add Facebook information to your application

  1. Sign in to the Azure portal and navigate to your App Service app.

  2. Select Settings > Authentication / Authorization, and make sure that App Service Authentication is On.

  3. Select Facebook, and then paste in the App ID and App Secret values that you obtained previously. Enable any scopes needed by your application.

  4. Select OK.

    Screenshot of Mobile App Facebook Settings

    By default, App Service provides authentication, but it doesn't restrict authorized access to your site content and APIs. You need to authorize users in your app code.

  5. (Optional) To restrict access only to users authenticated by Facebook, set Action to take when request is not authenticated to Facebook. When you set this functionality, your app requires all requests to be authenticated. It also redirects all unauthenticated requests to Facebook for authentication.

    Caution

    Restricting access in this way applies to all calls to your app, which might not be desirable for apps that have a publicly available home page, as in many single-page applications. For such applications, Allow anonymous requests (no action) might be preferred so that the app manually starts authentication itself. For more information, see Authentication flow.

  6. Select Save.

You're now ready to use Facebook for authentication in your app.

Next steps