OnePost

FREEMIUM
By Adam Darrah | Updated a month ago | Social
Popularity

8.5 / 10

Latency

954ms

Service Level

100%

Health Check

N/A

Back to All Tutorials (10)

Adding a Twitter Provider

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

Registering a Twitter App

In order for your application to use Twitter’s API (through OnePost), you must first register a Twitter Developer account from the Twitter Developer portal. Sign in to your Twitter account and enter your information to become a registered Twitter developer.

Once you have entered all required information, you will be taken to your Twitter Developer Dashboard. Create a new app to get started:

After creating your app, find the “Keys and tokens” section of the settings. Get your API key and secret by clicking on “Regenerate”.

Creating a Twitter Provider

Now that we have created our Twitter Developer App and have the API key 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 Twitter 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": "L5o...",
>         "api_secret_key": "1pK...",
>         "callback_url": null,
>         "type": "Providers::Twitter"
>     }
> }'

{"id":7,"type":"Providers::Twitter","api_key":"L5o...","created_at":"2021-02-19T16:50:15.858-05:00","updated_at":"2021-02-19T16:50:15.858-05:00","callback_url":null,"api_secret_key":"1pK..."}

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