Add Facebook Login

# Add Facebook Login

You can add Facebook login to your applications using Asgardeo and enable users to log in with their Facebook account.

Follow this guide for instructions.

# Register Asgardeo on Facebook

You need to register Asgardeo as an app on Facebook.

You can follow the Facebook Documentation (opens new window) for detailed instructions.

To register an app on Facebook:

  1. Log in to the Facebook developer portal (opens new window) and click Create App. Log on to Facebook developer portal

  2. Select Consumer as the app type and click Next. Create Facebook consumer app

  3. Provide Display Name and click Create App to create an application. Provide information to Facebook app

  4. Under Add products to your app, click Set up on the Facebook Login card. Add Facebook login

  5. Select Web type and provide the following Site URL with your organization name:{organization_name}
    Add Facebook app url
  6. Save the changes and click Continue.

  7. On the left panel, under Facebook Login, go to Settings and add the following as the Valid OAuth Redirect URIs:{organization_name}/commonauth
  8. Enable Client OAuth Login and Web OAuth Login (these are enabled by default) and save the changes. Add Facebook settings

  9. On the main panel, go to Settings > Basic and take note of the App ID and App Secret. Get AppID and Secret from Facebook

# Register the Facebook IdP

Now, let's register the Facebook IdP in Asgardeo.

  1. On the Asgardeo console, go to Develop > Connections.

  2. Click Create Connection and select Facebook.

  3. Enter the following details of the Facebook identity provider and click Finish:

    Add Facebook IDP in Asgardeo
    Parameter Description
    Name A unique name for this Facebook identity provider.
    App ID App ID obtained from Facebook.
    App Secret The app secret obtained from Facebook.

After the Facebook identity provider is created, go to the Settings tab and see the list of permissions granted by Facebook to Asgardeo.

  • email: Grants read access to a user's primary email address.
  • public_profile: Grants read access to a user's default public profile details.

Asgardeo needs these permissions to get user information. Asgardeo checks the attribute configurations of the application and sends the relevant attributes received from Facebook to the app. You can read the Facebook documentation (opens new window) to learn more.

# Enable Facebook login

Before you begin

You need to have an application registered in Asgardeo. If you don't already have one, register an application based on one the following application types:

  1. On the Asgardeo console, go to Develop > Applications.

  2. Open your application from the list and go to the Sign-in Method tab.

  3. If you haven't already defined a sign-in flow, click Start with Default configuration to get started.

  4. Click Add Authentication on the step, select your Facebook identity provider, and click Add.

    Add Facebook login in Asgardeo

# Try it out

Follow the steps given below.

  1. Access the application URL.
  2. Click Login to open the Asgardeo login page.
  3. On the Asgardeo login page, click Sign in with Facebook.
Login with Facebook
  1. Log in to Facebook with an existing user account.
  2. The user is now redirected to the application and logged in.

When a user successfully logs in with Facebook for the first time, a user account is created in the Asgardeo console with the Facebook username. This new user account will be managed by Facebook.