X/Twitter OAuth1 needed to post images with the X API

Hello,
We would like to be able to use n8n to automate social media posts containing images to X/Twitter. The only way to post images is via OAuth1. However, n8n has deprecated their support of OAuth1 as of version 0.236.0.

We think it would be beneficial to add this functionality back because we imagine we are not the only ones wishing to post images to X/Twitter using n8n automation.

Would it be possible to continue supporting OAuth1 for this purpose of uploading media to X/Twitter using n8n automation?

Thank you,
Sarah

Hi Sarah

I managed to post to X with image (single image only). I’m still struggling with videos, and that INIT > APPEND > FINALIZE method.

However, I’m facing an issue with authentication and scopes, that you can check here:

In order to upload image, I’m using HTTP request node and a generic OAuth2 credential.

Set grant type = PKCE
Authorization URL = https://x.com/i/oauth2/authorize
Access Token URL = https://api.x.com/2/oauth2/token
Scope = media.write offline.access

So, here is where i’m having issues. When I use media.write, I can’t use together with tweet.write. So I have to set up another credential (predefined X OAuth2) to post the tweet. You just have to carry the media_id. I’m using two workflows, one to upload image, and another to post the tweet with media_id. Still trying to figure out this issue.

Check this link to find the “Upload image” node. Just set the credential as described above, and chage the URL to https://api.x.com/2/media/upload

This way is working for me, but I’m still trying to solve the scopes / authentication issue.

Hope that helps!

1 curtida

Thank you so much for your help, @ericocheung! We will try this.

@sarah_n3t, did this work for you?

@Raphael-Joel_Lim shared the solution in my other post.

You have to add all scopes available to make it work. Just copy and paste:

tweet.read users.read tweet.write tweet.moderate.write users.read follows.read follows.write offline.access like.read like.write dm.write dm.read list.read list.write media.write

This way, you can use only the Generic Credential Type OAuth2 to upload the image and also post the tweet (w/ image).

Kudos to @Raphael-Joel_Lim!

Hi @ericocheung,
Thank you for sharing this update! I am in fact very lucky to have @Raphael-Joel_Lim as my coworker. We are working on this project together! Kudos to you both for your help :slight_smile:

Hi @ericocheung,

I’m having the same issue. I’ve been unsuccessful in uploading an n8n binary to X. This is the closest I’ve come, but it’s turning the binary into the source URL instead of uploading the binary to X.

What am I missing?

Any help would be appreciated :slight_smile:

Hey @Mark_M,

I’m using the “Upload image” HTTP request node from @MutedJam, and it’s working fine for me. :point_down:

1 curtida

Hi Erico - are you not getting the « Timestamp Out of Bounds » error message with this method?

It’s been working perfectly for me until yesterday.

Could someone help troubleshoot?

Sorry to hear that @museAI.
I never got the error you mentioned.
Could you explain more?
Not sure if I can help

Anyone could find a way to post media on X by N8N ?

Check out this tutorial - it helped me set this up. It’s in French, but has subtitles.

above link for 90997 is private or removed? I thought Id mention this if not know - X workaround with twitterapi.io. I’ve been running into the same OAuth1 deprecation headache for posting images to X. I have a an auto-posting flow that first generates a Meme Image, then combines with generted text for full X Quote Post tweet, or Reply tweet. I also stuck with the classic v1.1 media upload endpoint using a Generic OAuth1 credential in an HTTP Request node (it still works fine despite the warnings).

The flow: Flux AI create Meme image → GET binary from Flux URL → upload to https://upload.twitter.com/1.1/media/upload.json (multipart, binary media field) → grab media_id_string → feed it into twitterapi.io for the actual tweet/quote post.

I have begun using twitterapi.io to circumvent X restrictions on auto-posting. Im not a rep at all but its pretty under-the-radar but super cheap.

Maybe helpful to bridge the gap while OAuth2 setups (like mutedjam’s media.write one) get dialed in. The 1st part of this sample flow shows the nodes I used; Ggl Shts is optional but handles a ssn cookie factor needed for using that api.

X Post Image (1).json (7.0 KB)

In the near future I will be posting my entire project as solutions to various aspects of auto-posting to X.