Plugins
Templates
Template Setup Guides

Twitter OAuth 1.0a Plugin

Link to plugin page: https://zeroqode.com/plugin/twitter-oauth-10a-plugin-1580388207316x240833466550325570

Introduction

Many endpoints on the Twitter developer platform use the OAuth 1.0a method to act, or make API requests, on behalf of a Twitter account. For example, if you have a Twitter developer app, you can make API requests on behalf of any Twitter account as long as that user authenticates your app.

The plugin can do the following actions: 1. post a tweet 2. delete a tweet 3. retweet or cancel a retweet 4. Like a tweet 5. upload a timeline 6. get user details etc.

Prerequisites

You must have a developer account with Twitter to interact with the plugin. Create your development account at: https://developer.twitter.com/en/dashboard

Plugin Element

First of all put plugin element named “Twitter account” on the page of your app, this is needed to run events and states.

Plugin Setup

How to get Keys

The keys that you need are in your twitter developer account -> Your app -> Keys and Tokens

Plugin field ConsumerPublic and ConsumerSecret are Consumer API keys from dev account.

Same for Access tokens, access level should be Read & Write.

Setting up Keys in Plugin Settings

When you've got your keys from Developer Account, place them in plugin settings fields as shown:

Get OAuth tokens

  1. Request new token and authorize user

At first step the user should give access to his account, for that on a button click (or other user interaction you want) set the first action to Twitter:Get tokens This action is used in 2 steps, at first step set field Auth current step to step_1

For step_1 also set a callback url encoded at field Step 1: Callback URL

Leave empty other fields, will be used later in other workflow.

Right after that set next plugin action, Authorize user.

For field Oauth token set Result of step 1 (Get tokens) Step 1 Oauth token

2. Generate and save user’s tokens

This actions will redirect user to twitter authorization page, when the user is redirected back to your application, there are 2 events that should be configured.

  1. Event when user denied access to your application, it is called Twitteraccount A User denied access and you can do whatever you want to warn user about it.

2. The user gave access and tokens form callback are ready to use Here on the first action set Twitter:Get tokens (same action from step_1)

But set fields for step_2

Next save obtained tokens to current user for example:

To refresh tokens, set the same actions from step 1:

Plugin Events

  • A Twitter account Callback Tokens ready

  • A Twitter account User denied access

Plugin Actions

  • Twitter: Get tokens

  • Authorize user a Twitter account

  • Twitter: Post new tweet

  • Twitter: Delete tweet

  • Twitter: Get user details

  • Twitter: Retweet or cancel retweet

  • Twitter: Like tweet

  • Twitter: Search tweets

  • Twitter: Load timeline

Action Example - Post new tweet

To post a new tweet use action, Twitter: Post new tweet.

For this and other action you need OAuth tokens from Step_2, you should have them saved by now, in current user database.

This action return posted tweet ID, you can get it using Result of step 1: Tweet ID

Same tokens are used for other actions. See demo page for more actions.

Demo to preview the settings: