OnePost

FREEMIUM
By Adam Darrah | Updated 한 달 전 | Social
Popularity

8.6 / 10

Latency

950ms

Service Level

100%

Health Check

N/A

Back to All Tutorials (10)

Adding a Facebook (& Instagram) Provider

Before starting this tutorial, make sure you have obtained your required API keys for using OnePost.

Registering a Facebook (& Instagram) App

In order to use OnePost with Facebook and/or Instagram, you must first register a new Facebook Developer app using the Facebook Developer Platform. Once signed in, click “Create App” to add a new developer application:

Make sure you pick “Manage Business Integrations” when asked what you need your app to do. Then, add all additional required information.

Once you’ve created your Facebook App, it’s time to add the required products. First, add “Facebook login”:

Once added, in “Settings” add “https://api.getonepost.com/users/auth/facebook/callback” as the one and only “Valid OAuth Redirect URIs”. This will allow OnePost to collect the required information to function when a user logs in with Facebook.

Once this is saved, then it’s time to add the “Instagram Graph API” Product to our App.

Finally, go to your Facebook app’s basic settings page where you will find your App ID and Secret:

Creating a Facebook (& Instagram) Provider

Now that we have created our Facebook Developer App and have the API ID and secret, we can now create a Provider record in OnePost using the API. A Provider in OnePost represents any application that is capable of being authorized. Right now we support Twitter and Facebook, but in the future, we could add additional providers such as LinkedIn.

Let’s use the Create Provider Endpoint to add our Facebook Provider.

curl --request POST \
> --url 'https://onepost1.p.rapidapi.com/api/v1/providers?secret_key=sk-7a0...' \
> --header 'content-type: application/json' \
> --header 'x-rapidapi-host: onepost1.p.rapidapi.com' \
> --header 'x-rapidapi-key: 9d0...' \
> --data '{
>     "provider": {
>         "api_key": "420...",
>         "api_secret_key": "908...",
>         "callback_url": null,
>         "type": "Providers::Facebook"
>     }
> }'

{"id":8,"type":"Providers::Facebook","api_key":"420...","created_at":"2021-02-19T17:20:10.330-05:00","updated_at":"2021-02-19T17:20:10.330-05:00","callback_url":null,"api_secret_key":"908..."}

As you can see, we have now created a new Provider record in OnePost with an ID of 8. We can now use this provider to create a “Login to Facebook” button for our website.