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?
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. :