Twitter Authentication Issue with Long Query Search

I’m running into an authentication error when performing a complex search with twitter. Can someone help me with this?

The twitter search query below works fine in twitter or when I previously used it in a zap. But when I use it in the Twitter node I get an authentication issue.

lang:en “hiring” “remotejobs” filter:links -filter:news -from:incluzion -from:incluzionjobs geocode:43.010493,-92.101723,2770km

https://twitter.com/search?q=lang%3Aen%20%20"hiring"%20"remotejobs"%20filter%3Alinks%20-filter%3Anews%20-from%3Aincluzion%20-from%3Aincluzionjobs%20geocode%3A43.010493%2C-92.101723%2C2770km&src=typed_query

{"message":"Request failed with status code 401","name":"Error","stack":"Error: Request failed with status code 401\n    at createError (/home/jibril/n8n_jibril/node_modules/axios/lib/core/createError.js:16:15)\n    at settle (/home/jibril/n8n_jibril/node_modules/axios/lib/core/settle.js:17:12)\n    at IncomingMessage.handleStreamEnd (/home/jibril/n8n_jibril/node_modules/axios/lib/adapters/http.js:269:11)\n    at IncomingMessage.emit (events.js:412:35)\n    at IncomingMessage.emit (domain.js:470:12)\n    at endReadableNT (internal/streams/readable.js:1317:12)\n    at processTicksAndRejections (internal/process/task_queues.js:82:21)","config":{"url":"https://api.twitter.com/1.1/search/tweets.json","method":"get","headers":{"Accept":"application/json","Authorization":"OAuth oauth_consumer_key=\"SaICRnzNgCrjgwzU71pA2Lx34\", oauth_nonce=\"oPA99RSpw23E93h9F4r1UJOD81IK88U8\", oauth_signature=\"fJtn9WlB78AV14ypyGS9jXMv3hs%3D\", oauth_signature_method=\"HMAC-SHA1\", oauth_timestamp=\"1632920742\", oauth_token=\"1053835296805191680-K5SNCkHjorzGvwrNzfioVO4UTNqFH2\", oauth_version=\"1.0\"","User-Agent":"axios/0.21.4"},"params":{"q":"\"hiring\" \"remotejobs\" filter:links -filter:news -from:incluzion -from:incluzionjobs ","include_entities":true,"response_type":"recent","lang":"en","geocode":"43.010493,-92.101723,2770km","count":1},"transformRequest":[null],"transformResponse":[null],"timeout":300000,"xsrfCookieName":"XSRF-TOKEN","xsrfHeaderName":"X-XSRF-TOKEN","maxContentLength":-1,"maxBodyLength":-1,"transitional":{"silentJSONParsing":true,"forcedJSONParsing":true,"clarifyTimeoutError":false}}}

If I only include “hiring” “remotejobs” in the query then I don’t get the authentication issue, it only when I add the additional filters…

Hey @datdudejibril,

I tested it on v0.138.0 and it is working as expected for me. However, I ran the same query with version 0.139.1, and I also ran into a similar error. I am assuming that you’re also using the latest version (0.138.0 +). If that’s the case, please set the environment variable as described in this post: Get Cookie After Login - #11 by jan or downgrade to 0.138.0.

I’m also unable to post to Twitter with any of my workflows after upgrading to 0.140.0.

Thank you for linking to https://community.n8n.io/t/get-cookie-after-login/7842/11, setting N8N_USE_DEPRECATED_REQUEST_LIB=true works around the issue for now.

Hey @mattsches,

Welcome to the community :sparkling_heart:

Thank you for confirming this. We are working on a fix and hopefully it will be released soon :slight_smile:

1 Like

Fix got released with [email protected]

1 Like

Hello @datdudejibril

It looks like the way you’re trying to perform the search is different.

The string used for the website does not follow the same patterns for the API call.

I would recommend you set up your node like in the attached image. I have picked part of your query and turned them into node parameters.

Note that the search text is now only "hiring" "remotejobs" and I was unable to apply some of the filters, but I think the results can be satisfying.

Let me know if this works for you.

Thanks. I tried this way as well. Interestingly it worked in my zap. However in the note above 0.141.0 resolved the issue.

I’ll update and verify today. Thx.