huginn / huginn

Create agents that monitor and act on your behalf. Your agents are standing by!
MIT License
42.67k stars 3.74k forks source link

"Not found. Authentication passthru" error when trying to connect Twitter / X service #3405

Open BackedUpBooty opened 3 months ago

BackedUpBooty commented 3 months ago

Running Huginn in docker, I've seen some similar issues from years ago but I couldn't find a resolution on them.

I followed the setup instructions for adding the env variables for Twitter/X oauth (HUGINN_TWITTER_OAUTH_KEY/SECRET). My huginn domain is accessible remotely with no restrictions on Cloudlfare's side or my side. When attempting to connect the service through Huginn by clicking the 'Authenticate with Twitter' button I get a Not found. Authentication passthru error at the URL which is https://huginn.mydomain.com/auth/twitter. I have a local DNS redirect for my domain, it happens both inside and outside my LAN. I saw that someone mentioned it could be browser-related. I've tried with opera, firefox and chrome and got the same response.

Steps I've taken:

Logs: Relevant logs for inside the LAN:

foreman stdout | 12:50:35 web.1  | I, [2024-05-06T05:50:35.909608 #599]  INFO -- : [9a341620-bf84-488c-b661-fb55c9c9b389] Started GET "/auth/twitter" for 192.168.1.11 at 2024-05-06 05:50:35 -0700
foreman stdout | 12:50:35 web.1  | I, [2024-05-06T05:50:35.911789 #599]  INFO -- : [9a341620-bf84-488c-b661-fb55c9c9b389] Processing by OmniauthCallbacksController#passthru as HTML
foreman stdout | 12:50:35 web.1  | I, [2024-05-06T05:50:35.914754 #599]  INFO -- : [9a341620-bf84-488c-b661-fb55c9c9b389]   Rendered text template (Duration: 0.0ms | Allocations: 3)
foreman stdout | 12:50:35 web.1  | I, [2024-05-06T05:50:35.915261 #599]  INFO -- : [9a341620-bf84-488c-b661-fb55c9c9b389] Completed 404 Not Found in 3ms (Views: 1.8ms | ActiveRecord: 0.0ms | Allocations: 612)

and outside the LAN

foreman stdout | 12:59:26 web.1  | I, [2024-05-06T05:59:26.501416 #599]  INFO -- : [45a89f54-1a84-4586-ba23-ee7134d69ed1] Started GET "/auth/twitter" for 133.159.[redacted] at 2024-05-06 05:59:26 -0700
foreman stdout | 12:59:26 web.1  | I, [2024-05-06T05:59:26.504086 #599]  INFO -- : [45a89f54-1a84-4586-ba23-ee7134d69ed1] Processing by OmniauthCallbacksController#passthru as HTML
foreman stdout | 12:59:26 web.1  | I, [2024-05-06T05:59:26.504806 #599]  INFO -- : [45a89f54-1a84-4586-ba23-ee7134d69ed1]   Rendered text template (Duration: 0.0ms | Allocations: 1)
foreman stdout | 12:59:26 web.1  | I, [2024-05-06T05:59:26.505067 #599]  INFO -- : [45a89f54-1a84-4586-ba23-ee7134d69ed1] Completed 404 Not Found in 1ms (Views: 0.4ms | ActiveRecord: 0.0ms | Allocations: 179)

which would explain the 'Not found' error in the browser, but I can't figure out why. I couldn't find any other helpful logs when bashing into the container, though I may have just not found the right path (I found supervisord.log but it wasn't any help). Am I missing something in the container setup?

Environment in the compose is as follows (passed from a .env, though I've also tried the keys as explicit in the compose with the same outcome):

    environment:
      - DATABASE_HOST=huginn-mysql
      - DATABASE_NAME=$MYSQL_DATABASE
      - DATABASE_USERNAME=$MYSQL_USER
      - DATABASE_PASSWORD=$MYSQL_PASSWORD
      - SMTP_DOMAIN=$SMTP_DOMAIN
      - SMTP_USER_NAME=$SMTP_USER_NAME
      - SMTP_PASSWORD=$SMTP_PASSWORD
      - SMTP_SERVER=$SMTP_SERVER
      - SMTP_PORT=$SMTP_PORT
      - SMTP_AUTHENTICATION=$SMTP_AUTHENTICATION
      - SMTP_ENABLE_STARTTLS_AUTO=$SMTP_ENABLE_STARTTLS_AUTO
      - SMTP_SSL=$SMTP_SSL
      - EMAIL_FROM_ADDRESS=$EMAIL_FROM_ADDRESS
      - HUGINN_TWITTER_OAUTH_KEY=$TWITTER_OAUTH_KEY
      - HUGINN_TWITTER_OAUTH_SECRET=$TWITTER_OAUTH_SECRET

I also wiped the database and started with a new one with the Twitter OAUTH included from the beginning, just in case.

Thanks for any assistance and apologies if I've missed something super obvious.

shengliangd commented 1 month ago

Facing similar problem, no solution found yet.

virtadpt commented 1 month ago

I think this has to do with the Twitter API changing, but the Ruby gems that interact with it not being updated. Some of the changes have to do with API use pricing changing (there's very little you can do from the free tier, as of 2023), some of it is how unstable the API service as a whole has been for a while, some of it is that you have to look at the raw error messages now to see what's going wrong.