Huginn comes with a number of Twitter agents, but before they can be used you need to authenticate them. That process requires multiple steps, and they are not well documented.
The basics are described on the “Configuring OAuth applications” Wiki page.
For the Twitter integration one must know that you are using a single Twitter app for all users, but every Huginn user can (and should) have this app authenticated against their own Twitter account. Therefore if you want to use multiple Twitter accounts in Huginn, you need multiple Huginn users.
The steps required for me to get this working:
Create a Twitter App
With your Twitter account, login into the Twitter Developer site. Create a new app, fill out all the necessary details.
Very important: you have to specify two Callback URLs!
https://<your Huginn site>/auth/twitter
https://<your Huginn site>/auth/twitter/callback
The two callbacks need to be in that order, otherwise the authentication will not work.
Write down the Consumer API key
& secret
, and the Access token
& secret
. This needs to be added to Huginn in the next step.
Add the Twitter App as Service in Huginn
Connect to your Huginn instance using ssh, and edit the .env
file. You need to add/enable two lines:
TWITTER_OAUTH_KEY
TWITTER_OAUTH_SECRET
In my case the entire installation is deployed using Ansible, and I’m using the lineinfile module to update the file:
|
|
After changing the .env
file, Huginn must be restarted.
Authenticate the Twitter App as user in Huginn
If there are no errors in the log after the restart, login into Huginn using a regular user. Click on Services
, and then on Authenticate with Twitter
.
This will redirect to the Twitter website, you have to login there with your credentials, and authenticate the app for this account. Afterwards Twitter will redirect back to the Huginn installation, using the two callback links which are specified in the app settings.
Use Twitter Agents
Now that the app is authenticated, Twitter agents can be added. See other blog posts and the documentation for this.
If you want to use multiple Twitter accounts, create multiple Huginn accounts. Each account can use it’s own Twitter credentials.