# Authorizing Facebook APIs in Astera

Facebook uses HTTP-based APIs that can be utilized to extract or load data, to and from Facebook. You can configure Facebook APIs for use in Astera using the ‘Custom API’ source in the REST API Browser (Beta).

To authorize a Facebook API in Astera, follow the steps below.

1. Click [here ](https://developers.facebook.com/)and log in.

{% hint style="info" %}
**Note:** If you have not created an account yet, you need to create one first after signing in.
{% endhint %}

![](https://3891069449-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F28dJIkGHacXhBlux3efx%2Fuploads%2Ff1z25AwkCeFwVoUeP3Fu%2F0.jpeg?alt=media)

2. Enter your Facebook account credentials to log in.

![](https://3891069449-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F28dJIkGHacXhBlux3efx%2Fuploads%2FRGSNRYN2RhEJrW8N5qz9%2F1.png?alt=media)

3. Go to *My Apps > Create App* to create an application.

![](https://3891069449-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F28dJIkGHacXhBlux3efx%2Fuploads%2FMW3tGacCkb5ImSipXMkg%2F2.png?alt=media)

4. Provide the *Display Name* for your application, and click *Create App ID*.

![](https://3891069449-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F28dJIkGHacXhBlux3efx%2Fuploads%2FqTHFH8ODow9p2t6X0H2V%2F3.png?alt=media)

Once your application is created, it will show under the *My Apps* tab.

![](https://3891069449-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F28dJIkGHacXhBlux3efx%2Fuploads%2FVC0xasQ1c6PNlxguwIVm%2F4.png?alt=media)

5. Click *Centerprise* to open the dashboard.

![](https://3891069449-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F28dJIkGHacXhBlux3efx%2Fuploads%2Fz33Ro7iL1IcBhwv7JZbw%2F5.png?alt=media)

6. Click on *Settings > Basic* to get the relevant credentials.

![](https://3891069449-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F28dJIkGHacXhBlux3efx%2Fuploads%2FVoScvg3IHB4FeqZ9s9rM%2F6.png?alt=media)

7. Here you can see the *App ID* and *App Secret*. Save this information to use later for authentication.

![](https://3891069449-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F28dJIkGHacXhBlux3efx%2Fuploads%2FKf2fN4yBm0T4FnqLc1J4%2F7.png?alt=media)

8. To use *Bearer Token* authentication, go to *Tools > Graph API Explorer*.
9. Click *Generate Access Token* and copy the token.

![](https://3891069449-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F28dJIkGHacXhBlux3efx%2Fuploads%2FuqakrjjEEbeZCtgfYft5%2F8.png?alt=media)

10. To access and try out different APIs, go to *Tools > Graph API Explorer*.

![](https://3891069449-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F28dJIkGHacXhBlux3efx%2Fuploads%2FEHV5vd25WhreRiX0ABRe%2F9.png?alt=media)

11. Select anything from the drop-down list.

![](https://3891069449-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F28dJIkGHacXhBlux3efx%2Fuploads%2FbkX1hEgEH5W3vmqgurlf%2F10.png?alt=media)

12. Click *Submit*, to see the results.

![](https://3891069449-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F28dJIkGHacXhBlux3efx%2Fuploads%2FSmayXUKf8sDttl8Vm7J8%2F11.png?alt=media)

13. Import the API in Astera using the *Import API* option in the REST API Browser (Beta). Select *API Import Source* as *Custom API* by providing *Name* and *Base Url*.

![](https://3891069449-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F28dJIkGHacXhBlux3efx%2Fuploads%2F4pIrxDoiwxTj9PUVKsjz%2F12.png?alt=media)

14. Now, you need to authenticate the Facebook APIs to use them in your dataflow. Without authentication, you will get an error. To authenticate an API, go to the *Project Explorer* panel and double-click on the API’s .sact file under the *Shared Connection* node.

![](https://3891069449-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F28dJIkGHacXhBlux3efx%2Fuploads%2FwWCN8OfMN6cVJ5HJGZwy%2F13.png?alt=media)

Facebook’s .sact file will open on the designer. Now, right-click on the shared action file’s header and select *Properties*. This will open the *REST API Connection* window, where you can configure the settings to authenticate Facebook’s API.

![](https://3891069449-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F28dJIkGHacXhBlux3efx%2Fuploads%2FaVJa7kisXV427c9hg18J%2F14.png?alt=media)

Facebook uses ‘*OAuth 2*’ authentication with *Grant Type*, ‘*Authorization Code*’.

* *Auth Url*: <https://www.facebook.com/dialog/oauth>
* *Access Token Url*: <https://graph.facebook.com/oauth/access\\_token>

Provide the *ClientID* and *Client Secret* that you had saved earlier, then click on *Request token* to generate the access token for Facebook.

![](https://3891069449-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F28dJIkGHacXhBlux3efx%2Fuploads%2Fp6HJlk23YACB8ryoCxwu%2F15.png?alt=media)

{% hint style="info" %}
**Note:** As you click on *Request Token*, Facebook’s login window will open where you will have to provide your credentials to generate the access token to access Facebook API.
{% endhint %}

![](https://3891069449-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F28dJIkGHacXhBlux3efx%2Fuploads%2FEi4YGMpuzdshZxAv5s8E%2F16.png?alt=media)

15. Save the shared action file after authentication and you are ready to use Facebook APIs in Astera. For more information on how to use a Custom API in Astera, click [here](https://documentation.astera.com/astera-data-stack-v9/api-flows/api-consumption/consume/rest-api-browser).

This concludes authenticating the Facebook APIs in Astera.
