Twitter image using HTTP node error 401

I am also facing the same issue… basically… with the new X node, to be able to post a tweet with an image, you need a media id, but with the oauth2 x api, that is not available on the free plan.

You can get a media id using the old api, but you need to authenticate via oauth1, so I have been trying to create a credential via x oauth credential type but I continuously get the 401 error… Not sure if x did something on there end to “plug” the hole or end the work around to force people to pay for the new api maybe?

I think that.

@AhmedAlnaqa

have you try with this?

No… but how to use it?
If u mind, show me the node setting.

Solved

First, we need to upload the file using API v1.1 using the HTTP request node but u have the following header:

1- Authorization: OAuth oauth_consumer_key=“API_KEY”, oauth_token=“ACCESS_TOKEN”, oauth_signature_method=“HMAC-SHA1”, oauth_timestamp=“TIMESTAMP”, oauth_nonce=“NONCE”, oauth_version=“1.0”, oauth_signature=“SIGNATURE”

2- cookie: guest_id=v1%3A173450663175949164;lang=en;

in body:

  • n8n binary file : media : data

options:

  • redirections : max : 21

after that, u will be using the Twitter node with API v2 to tweet the text and the media file uploaded from step 1 " HTTP request node"

in the options of the Twitter node add:
media file with media_id_string value

That’s it.
and thanks for @mredodos

great news, will test out shortly… great work!

the cookie is required?

this is my test . just try it

Can you tell me how to get the oauth_nonce and oauth_signature?

I used the GPT to generate CURL code and then used Postman to check the right parameters

@AhmedAlnaqa Appreciate if you can share the screenshot and let us know if you are using the latest version of n8n.

Hello,
If you are interested, I made an explanatory video for the solution: https://www.youtube.com/watch?v=ar9Z68ASvkM
Thank @AhmedAlnaqa and @mredodos :slight_smile:

awesome, I will watch when I get time and try it out, thank you

sure,

How did you generated the value of oauth_nonce and oauth_signature in HTTP REQUEST node. ?

You have to add it as a key-value … that’s all

just add the values mentioned in the solve post

Thanks Ahmed. I finally found a way to use Code and build it up without any issues. Now my Twitter is working perfectly fine without any issues.

That’s fantastic news! :tada: I’m so glad to hear everything is working perfectly for you now.

OTHER METHOD :

The solution provided wouldn’t work for me on my self-hosted instance (same in the cloud btw). So I downgraded to 1.68.1 as suggested by a user (sorry I can’t recall where), made the connection to X OAuth on this version and then went back to the current version and it works.

The process is “just” to change the image to n8nio/n8n:1.68.1 in the compose file, do the connection then go back to n8nio/n8n.

When stopping the image to restart make sure to never delete anything.

Hope it helps.

I also tried a script in a node to generate the OAuth chain provided in the solution but it wouldn’t work neither. Might work for someone. :

Great, thx