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!

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 Like

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.