Skip to content

Commit

Permalink
Added generic connector for Twitter API
Browse files Browse the repository at this point in the history
  • Loading branch information
Mitchell Dodell committed Jul 6, 2020
1 parent 483ca07 commit 9b21d0f
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 0 deletions.
57 changes: 57 additions & 0 deletions examples/generic_connector_configs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* [OAuth 2.0 API](#oauth-20-api)
* [Slack Web API](#slack-web-api)
* [Splunk API](#splunk-api)
* [Twitter API](#twitter-api)
* [Contributing](#contributing)

## Introduction
Expand Down Expand Up @@ -217,6 +218,62 @@ to the backend server uses SSL.

___

### Twitter API
This example can be used to interact with [Twitter's API](https://api.slack.com/apis).

The configuration file for the Splunk Web API can be found at [twitter_secretless.yml](./twitter_secretless.yml).

**Note:** This configuration currently only supports connecting to the Twitter API via OAuth2. An issue can be found here for adding an OAuth1 Connector for
Twitter.

#### How to use this connector
* Edit the supplied service configuration to get your
[OAuth token](https://developer.twitter.com/en/docs/basics/authentication/oauth-2-0/bearer-tokens)
* Run secretless with the supplied configuration(s)
* Query the API using `http_proxy=localhost:8051 curl api.twitter.com/{Request}`

#### Example Usage
<details>
<summary><b>How to use this connector locally</b></summary>
<ol>
<li>
Get your
<a href="https://developer.twitter.com/en/apps">
Twitter API key and Secret Key
</a>
</li>
<li>
Get an
<a href="https://developer.twitter.com/en/docs/basics/authentication/oauth-2-0/bearer-tokens">
OAuth token
</a>
from Twitter through CURL
</li>
<code>
curl -u 'API key:API secret key' \
<br />
--data 'grant_type=client_credentials' \
<br />
'https://api.twitter.com/oauth2/token'
</code>
<li>Save the local token from the request into the OSX keychain</li>
<li>Run Secretless locally</li>
<code>
./dist/darwin/amd64/secretless-broker \
<br />
-f examples/generic_connector_configs/twitter_secretless.yml
</code>
<li>
On another terminal window, make a request to Twitter using Secretless
<li>
<code>
http_proxy=localhost:8051 curl "api.twitter.com/1.1/followers/ids.json?screen_name=twitterdev"
</code>
</ol>
</details>

___

## Contributing

Do you have an HTTP service that you use? Can you write a Secretless generic
Expand Down
16 changes: 16 additions & 0 deletions examples/generic_connector_configs/twitter_secretless.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: 2
services:
twitter-oauth2:
connector: generic_http
listenOn: tcp://0.0.0.0:8051
credentials:
token:
from: keychain
get: summon#twitter/bearer-token
config:
headers:
authorization: Bearer {{ .token }}
content-type: application/json
forceSSL: true
authenticateURLsMatching:
- ^http[s]*\:\/\/api\.twitter\.com*

0 comments on commit 9b21d0f

Please sign in to comment.