# Facebook

Create or log into your Developer’s account at <https://developers.facebook.com/>

* [ ] Create Facebook OAuth App in Meta Developer Portal
  * [ ] Add Privacy Url to App Settings
  * [ ] Request Advanced Access For Public Profile
  * [ ] Add Facebook Login and Valid OAuth Redirect URL
  * [ ] Complete [Data Use Checkup](https://developers.facebook.com/docs/development/maintaining-data-access/data-use-checkup)
* [ ] Ensure access to Facebook Pages
  * [ ] Facebook Account should have a Page Role
* [ ] Set up app credentials in your Middle Facebook App
  * [ ] Create an API Key using app credentials from developer app
* [ ] Connect Middle accounts
  * [ ] Add Facebook integration
  * [ ] Connect via OAuth

## **Facebook Account** <a href="#v1k5x5g72at6" id="v1k5x5g72at6"></a>

To connect Facebook in Middle, you will need a Facebook OAuth developer app. This is what’s used to authenticate your Middle Facebook app. You will need a Meta Developer account to create an OAuth app. Subsequently, a Meta Developer account requires a Facebook login (a Facebook account).

Log into the Facebook account before moving to the next step.

{% hint style="info" %}
We recommended that you consider [creating a Facebook Accoun](https://www.facebook.com/reg/)t that will solely be responsible for maintaining this integration. By creating an integration-specific account, anyone on your team can access this Facebook account and the developer portal. You can also use a trusted business account or personal account. The trade-off is that access to this account might be limited if there is an authentication issue your team needs to address.
{% endhint %}

{% hint style="danger" %}
For lead retrieval, Facebook requires re-authentication every 90 days and for an account to have a Page Role on the Facebook Pages it’s connecting to.

Facebook will lose connection and require re-authentication if a Facebook account’s password is changed or if the user is locked out.
{% endhint %}

## **Meta Developer Account** <a href="#id-28thtjgr4z4j" id="id-28thtjgr4z4j"></a>

Login or Create a Developer’s account at <https://developers.facebook.com/>.

This developer account will be an admin of the Facebook OAuth app you create for your integration.

## **Facebook OAuth App** <a href="#d3ngbxpcuz6k" id="d3ngbxpcuz6k"></a>

### **Create Facebook OAuth App** <a href="#id-9oty95jjn7c4" id="id-9oty95jjn7c4"></a>

On the [App Dashboard](https://developers.facebook.com/apps/):

1. Click **Create App**
2. Select an app type: **Business**
3. Provide an App Name, contact email, and (optional) a Business Account to connect to
4. Click **Create App** to finish

<figure><img src="/files/qf6xYq3wsX5pFP4bQ1K5" alt=""><figcaption><p>The Meta Developer App Dashboard</p></figcaption></figure>

### **Add Privacy Url to App Settings** <a href="#id-5hk1rgnoyc4y" id="id-5hk1rgnoyc4y"></a>

On your navigation bar within your new App:

1. Click **Settings**, then click **Basic**
2. Add [**https://info.perkville.com/privacy**](https://info.perkville.com/privacy) to your Privacy URL
3. Click **Save Changes** to finish

<figure><img src="/files/NyHSrdoTY311bsGsTXoD" alt=""><figcaption><p>An app's basic settings and privacy policy URL</p></figcaption></figure>

### **Request Advanced Access For Public Profile** <a href="#pullq0d9y5q2" id="pullq0d9y5q2"></a>

Facebook Login requires the public\_profile permission to have advanced access. This will have you agree to the terms for using Facebook Login.

1. Under **App Review**, click **Permissions and Features**
2. Locate the **public\_profile** permission and click **Get Advanced Access**
3. Accept the terms and verify your password

<figure><img src="/files/4fJ23WqB1PK5qkgqnU9m" alt=""><figcaption><p>An app's permissions and features</p></figcaption></figure>

### **Add Facebook Login** <a href="#id-4gxzdbqfcqxz" id="id-4gxzdbqfcqxz"></a>

1. Click **Add Product** next to Products on the left-hand navigation
2. Click **Set Up** under Facebook Login

<figure><img src="/files/On1Mr7fnADilk8BVfsRO" alt=""><figcaption><p>Add products to an app</p></figcaption></figure>

### **Add Valid OAuth Redirect URIs**

You will need to add a valid OAuth Redirect URI for your Middle instance for Facebook Login to work for OAuth.

1. Go to **Settings** under Facebook Login when it appears on the left-hand navigation
2. Add your redirect URI to Valid OAuth Redirect URIs:\
   [     https://YOURINSTANCE.middle.app/oauth-redirect-uri/](https://yourinstance.middle.app/oauth-redirect-uri/)
3. Click **Save Changes**

<figure><img src="/files/eyMuLQ4ErjECdKhPMLfd" alt=""><figcaption><p>Facebook Login Settings and Valid OAuth Redirect URIs</p></figcaption></figure>

## **Complete** [**Data Use Checkup**](https://developers.facebook.com/docs/development/maintaining-data-access/data-use-checkup) <a href="#id-3waqnrasi7a4" id="id-3waqnrasi7a4"></a>

**Data Use Checkup is a requirement that must be completed once per year by an app admin to continue API access.**

{% hint style="danger" %}
Failure to complete an annual data use checkup will deactivate your Facebook OAuth app
{% endhint %}

This checkup will have you re-verify your public\_profile permissions acknowledgment and review Platform Terms and Developer Policies.

A popup should appear when you try to access your app’s dashboard again or under your Alerts section. Complete the prompts required by this checkup.

## **Facebook Pages** <a href="#n0tyztx49z2q" id="n0tyztx49z2q"></a>

To use Facebook Login OAuth, you will use a Facebook account to connect your integration to Middle.

In order to access Facebook Page data, this Facebook account will need to have a [Page Role](https://www.facebook.com/help/289207354498410) on the Facebook Pages you are trying to access. They will either need Facebook Access (Admin, Editor) or Task Access (Moderator, Advertiser).

A Facebook Developer OAuth app also requires this Facebook account to have a developer account and role on the OAuth app in order to retrieve information regarding Page and Lead data, if this has not undergone Facebook App review to be made public.&#x20;

{% hint style="warning" %}
Because the Facebook App review process is extensive and is only necessary when you want external organizations to use your app, we recommend leaving this OAuth app in developer/internal mode.
{% endhint %}

### **Add Page Roles for Facebook Account**

1. Navigate to your Facebook Page and use **Settings** to access your **Page Roles**.
   1. If you are using Meta Business Suite, **Page Settings** should be under **All Tools** on your sidebar
2. If the Facebook Account doesn’t already have a Page Role assigned, **assign one of the valid Page Roles** (Admin, Editor, Moderator, Advertiser).

### **Ensure Facebook Account has role on Facebook Oauth app** <a href="#ys02xhmrmirb" id="ys02xhmrmirb"></a>

If you are using a **Facebook account** to authenticate that also **created the developer OAuth app:**

1. Because your Facebook account is already an admin of the developer OAuth app, no further action is needed.

If you are using a **Facebook account** to authenticate that did not create the developer OAuth ap&#x70;**:**

1. You will need to have an OAuth app role in order to use Facebook Login successfully.
2. The Facebook account will **need to have or** [**create a developer account** ](https://developers.facebook.com/)in order to be added to the OAuth app roles.
3. The Meta Developer Admin for your Facebook Developer OAuth app will need to **add this Facebook Account as an Admin, Developer, or Tester** within Roles.
4. This Facebook Account will need to **accept the invite in their Meta developer portal**

## **Middle Facebook Credentials** <a href="#id-358b7422zbp4" id="id-358b7422zbp4"></a>

Within your Middle instance, you will have a Facebook app that manages how Facebook integrates to Middle. In order to use Facebook Login OAuth, you will need to add the OAuth App Credentials to your Middle Facebook app.

### **Grab App Credentials** <a href="#mnv1dot72jj3" id="mnv1dot72jj3"></a>

You can find your App Key and App Secret from your Facebook OAuth app under **Settings**, then **Basic**.

### **Create API Key With Credentials** <a href="#id-67v0jibonagw" id="id-67v0jibonagw"></a>

The API Keys section of the Facebook app on Middle allows you to store client credentials for use when scripting. These credentials can be made available globally to your accounts on your instance that want to use the Facebook integration.

1. Navigate to your Middle Facebook app
2. **Create a new API Key**
3. Provide a name (ex: My Business Facebook App)
4. Toggle "is default" to on if you would like all accounts to use the same credential
5. Replace your credentials below and copy and paste this dictionary into the payload:    \
   `{`

   `"APP_ID": "******************",`

   `"APP_SECRET": "***************"`

   `}`
6. If you only want certain accounts to access these credentials, you can determine them on this page using Allowed Accounts
7. Click **Save**

<figure><img src="/files/4Ff7IdAL1tnoVFwGrmb6" alt=""><figcaption><p>API Key configuration window</p></figcaption></figure>

### **Connect Account(s) To Facebook** <a href="#id-7oj9zpmp6h58" id="id-7oj9zpmp6h58"></a>

Now you are ready to connect your Middle Accounts to the Facebook integration.

Select an account you want to connect to Facebook on Middle by clicking **Accounts** and then the account name.

### **Add Facebook To Account** <a href="#id-49j9crn6pek3" id="id-49j9crn6pek3"></a>

If Facebook is **not** already in the App Connections:

1. Click **+ New App Connection**, select **Facebook**, and click **Add New Connection.**
2. Enter a **name** (Facebook) and hit **Save** to create the connection.
3. Your App Connection Screen will then load. If you are using a default API Key, you can leave API Key as is. Otherwise, you can select the appropriate API Key from the dropdown and click Save.

### **Authorize Using OAuth** <a href="#pr5z4xmvbi0x" id="pr5z4xmvbi0x"></a>

If it is your first time Authenticating:

1. Click **Launch OAuth Flow,** then **Launch OAuth Process**
2. You will be prompted to continue as the currently logged in Facebook Account, or can click *Log Into Another Account* to switch accounts. **Be sure to log in as the Facebook** Account **who has both a Page Role and a Meta Developer Role.**
3. **Select the Facebook Pages** you would like to retrieve Lead Data from. *Reminder: you must have a Role on these Pages.* Then click **Next.**
4. Click **Done,** then click **OK**

If Facebook connection already exists, click **Edit Connection Details.**

<figure><img src="/files/vlCvLaAzHhkjQpsLHbfk" alt=""><figcaption></figcaption></figure>

1. Click **Launch OAuth Flow,** then **Launch OAuth Process**
2. Click **Edit Settings** and ensure your Facebook Pages are selected, then click **Next.** *Reminder: you must have a Role on these Pages*
3. Click **Done,** then click **OK**

You will then be redirected to Middle. It should say whether the connection was successful, or if there was an error. You can click View Invocation to view any error responses.

You should now be ready to start synching your Facebook Page Leads to Middle.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.middle.app/middle-docs/guides/app-reference/facebook.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
