Configure your App Service or Azure Functions app to use Facebook login
This article shows how to configure Azure App Service or Azure Functions 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.
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.
Select My Apps > Add New App.
In Display Name field:
- Type a unique name for your app.
- Provide your Contact Email.
- Select Create App ID.
- Complete the security check.
The developer dashboard for your new Facebook app opens.
Select Dashboard > Facebook Login > Set up > Web.
In the left navigation under Facebook Login, select Settings.
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.
Select Save Changes.
In the left pane, select Settings > Basic.
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.
The app secret is an important security credential. Do not share this secret with anyone or distribute it within a client application.
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.
Sign in to the Azure portal and navigate to your App Service app.
Select Settings > Authentication / Authorization, and make sure that App Service Authentication is On.
Select Facebook, and then paste in the App ID and App Secret values that you obtained previously. Enable any scopes needed by your application.
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.
(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.
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.
You're now ready to use Facebook for authentication in your app.
- App Service Authentication / Authorization overview.
- Advanced usage of authentication and authorization in Azure App Service
- Tutorial: Authenticate and authorize users end-to-end in Azure App Service
- Add authentication to your Mobile App: iOS, Android, Windows Universal, Xamarin.Android, Xamarin.iOS, Xamarin.Forms, Cordova.