How to configure applications on Facebook

Created on 19 February 2024, over 1 year ago

Problem/Motivation

After reading the module documentation, I still don’t understand how to configure applications on Facebook.
1. On the page https://developers.facebook.com/apps/creation/ what to choose: “Authenticate and request data from users with Facebook Login” or “Other”?
2. If you select "Other", then which "app type" should you choose?
3. Is it necessary to create a “Business Account” in the next step?
After creating the application, it requires me to create and confirm a “Business Account”
4. What “products” should you add to your application?
5. What other steps need to be taken before publishing the application?

Now, on the user profile editing page, when I try to add an account, I see the following message:

Application is inactive
This application is currently unavailable and the developer is already aware of the problem. Once the app is reactivated, you will be able to sign in.

💬 Support request
Status

Active

Version

3.0

Component

Documentation

Created by

🇺🇦Ukraine proweb.ua

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @proweb.ua
  • 🇺🇸United States MegaKeegMan

    Sorry this has taken so long. This module has been in a halfway state for a little while now, and a big part of the reason is that working with facebook is so complicated. We had made it through this process once. I will put my notes here, and then make sure that they make it somewhere more prominent before closing this issue.

    Requirements:

    • Facebork account
    • Business/other page with permissions to manage that page (create posts, etc)

    To create an application on Facebook

    The Application is what your web site will use to authenticate to Facebook and ask a user to grant privileges to post to your pages. You'll need the Application created and to add it's settings to your Drupal configuration so that it can prompt to request permissions. Essentially, the Application acts as an agent for your website to create posts.

    Go to the developer center at https://developers.facebook.com/ and go to "My Apps"

    Create an application:

    Provide some name and an email for the application. The name of the application will appear on posts as the "Published by"

    For permissions, select the use case "Manage everything on your Page".

    There's no requirement to select a business portfolio for this application.

    Click next until you are able to complete creating the application.

    Ensure you are on the application dashboard. This should be where you land on upon creating the app. If not, select the application in the list of applications.

    Select the "Customize the Manage everything on your Page use case", and ensure the following permissions are granted:

    • pages_manage_posts
    • pages_show_list
    • public_profile
    • email
    • pages_read_engagement (seems needed on use case, but not on business configuration?)

    Click Add next to any that are not enabled. No additional permissions should be needed, so remove others if you'd like.

    Return to the application dashboard, and expand the Facebook Login for Business and go to the settings.

    Add Valid OAuth Redirect URIs to reach back to your application. You'll want to add one for each domain you need to reach. For example, to reach a live example domain and also test with your DDEV instance, add:
    https://example.ddev.site/user/social-post/facebook/auth/callback
    https://example.com/user/social-post/facebook/auth/callback

    Now add a login configuration. This is also under Facebook Login for Business called Configurations.

    Call the configuration anything you like, for example "user_login".
    Use the general login variation.
    Select user access token.
    Under permissions, add the pages_manage_posts, email, pages_read_engagement, and pages_show_list permissions. When finishing the creating the configuration, make note of/copy the configuration ID (you can still get this from the configuration list if you missed it).

    This should be sufficient configuration to use your app. Now, acquire the ID/secret you'll need - along with the configuration ID - to add to Drupal.

    On the left, under App Settings, go to the Basic Settings. Copy the following:

    App ID
    App Secret

    Then under App Settings go to the Advanced Settings. Make note of the API Version. Remember this location - Facebook will periodically deprecate API versions, and this value may need to be changed in the future.

    # Configure Drupal

    Add your App ID, App Secret, and Configuration ID to your Drupal configuration at `/admin/config/social-api/social-post/facebook`. Also ensure the API version matches what was listed in the advanced settings of the application.

    If you prefer to keep your settings in your `settings.php` (or e.g. `settings.local.php` as applies to your usage style/environment), the structure looks like this:

    $config['social_post_facebook.settings'] = [
      'app_id' => '1234567890123456',
      'app_secret' => 'bMYAPPSECRETETC',
      'graph_version' => '23',
      'config_id' => '0987654321098765',
      'oauth_redirect_url' => 'https://example.ddev.site/user/social-post/facebook/auth/callback',
    ];
    

    *Dev note: the oauth_redirect_url should default to Drupal's hostname/user/social-post/etc... if it does not already*

    # Connect your facebork user to your Drupal instance

    When logged in as the user you want to associate with your Facebook account, go to your users edit page, and click "Add account" under the Social Post Facebook section.

    During this process, ensure you select the option "Opt in to current Pages only", and select ONLY the one page that you will want to allow the app to post as.

    # Create a page

    Creating a page is pretty straightforward. Logged in, on the main facebook page, click on see more in the left sidebar. Then click "pages". From there, click "Create new page" and just follow the prompts until your page is complete. Once done, navigate to your page, and you can find your page id by clicking "About" and then "Page transparency".

    **To be removed:** This is also a convenient time to acquire the Page ID, which is also needed in settings for Drupal to know what page ID to post to. If you do not get it here, see the "Create a page" above for another way to find it.

    The page ID then also goes in `settings.php` as:

    $settings['facebook_page_id'] = '123456789012345'; (planning to change this soon)

  • 🇺🇸United States MegaKeegMan

    I think the use-cases pattern that facebook has added does make some of this a little bit easier than it used to be, but it is still pretty convoluted

  • 🇺🇸United States MegaKeegMan

    I have added the above documentation to the readme as well. If anyone wants to take a look, and maybe try to follow along, that would be helpful. These instructions should enable you to auhorize posting to a page on behalf of your account. Having an account show up in the table on your user page is a good measure of success here.

  • 🇺🇸United States MegaKeegMan

    The documentation is now on the project page. I recommend anyone looking to review follow the instructions there. I will keep this open for now until I get some feedback.

Production build 0.71.5 2024