> For the complete documentation index, see [llms.txt](https://docs.appstrategy.com/apprules-r-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.appstrategy.com/apprules-r-documentation/platform/platform-features/system-settings/data-sources/connection-settings/socialnetworks/facebook.md).

# Facebook

### Connecting to Facebook <a href="#connecting-to-facebook" id="connecting-to-facebook"></a>

The following are optional connection properties:

* Target: Some Facebook tables can be filtered by a target. For example, to retrieve comments on a video, specify the Id of the video as the target. This property enables you to restrict the results of all queries in the connection to records that match the specified target. You can also specify this restriction per query with the Target column.
* AggregateFormat: The provider returns some columns as a string aggregate. For example, the available likes data for an entity is returned in aggregate. By default, the provider returns aggregate columns in JSON. You can also return aggregates in XML.
* Version: Set this property to the Facebook API version if you need to work with a different version than the default.

### Authenticating to Facebook <a href="#authenticating-to-facebook" id="authenticating-to-facebook"></a>

Facebook uses the OAuth standard to authenticate users.

#### OAuth <a href="#oauth" id="oauth"></a>

In all OAuth flows, you must set AuthScheme to OAuth. The sections below assume that you have done so.

See [Creating a Custom AzureAD App](/apprules-r-documentation/appendix/miscellaneous/creating-a-custom-azure-oauth-app.md) for information about creating custom applications.

#### Authentication

* InitiateOAuth: Set this to GETANDREFRESH. You can use InitiateOAuth to avoid repeating the OAuth exchange and manually setting the OAuthAccessToken.
* OAuthClientId: (custom applications only) Set this to the client Id in your application settings.
* OAuthClientSecret: (custom applications only) Set this to the client secret in your application settings.
* CallbackURL: Set this to the Redirect URL in your application settings.
* Scope (optional): Set this if you need to customizie the permissions that the driver requests.
* AuthenticateAsPage (optional): Set this to a page name or Id to make requests as a page. The page must be managed by the authenticated user.

When you connect the provider opens the OAuth endpoint in your default browser. Log in and grant permissions to the application. The provider then completes the OAuth process:

1. Extracts the access token from the callback URL.
2. Obtains a new access token when the old one expires.
3. Saves OAuth values in OAuthSettingsLocation. These values persist across connections.

&#x20;

&#x20;


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.appstrategy.com/apprules-r-documentation/platform/platform-features/system-settings/data-sources/connection-settings/socialnetworks/facebook.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
