I’ve updated to 0.236.0 of n8n and have added my credentials to Twitter OAuth2 API.
I’ve updated my callback URL in the Twitter Developer Portal to https://n8n.mydomain.com/rest/oauth2-credential/callback
I cannot upload an image to Twitter via the HTTP Request to node (using these instructions, to https://upload.twitter.com/1.1/media/upload.json) using the Twitter OAuth2 API credentials. It returns the error:
{
"status":
"rejected",
"reason":
{
"message":
"Forbidden - perhaps check your credentials?",
"timestamp":
1689100303571,
"name":
"NodeApiError",
"description":
"403 - """,
"context":
{
},
"cause":
{
"message":
"403 - """,
"name":
"Error",
"stack":
"Error: 403 - "" at createError (/usr/local/lib/node_modules/n8n/node_modules/axios/lib/core/createError.js:16:15) at settle (/usr/local/lib/node_modules/n8n/node_modules/axios/lib/core/settle.js:17:12) at RedirectableRequest.handleResponse (/usr/local/lib/node_modules/n8n/node_modules/axios/lib/adapters/http.js:238:9) at RedirectableRequest.emit (node:events:525:35) at RedirectableRequest.emit (node:domain:489:12) at RedirectableRequest._processResponse (/usr/local/lib/node_modules/n8n/node_modules/follow-redirects/index.js:356:10) at ClientRequest.RedirectableRequest._onNativeResponse (/usr/local/lib/node_modules/n8n/node_modules/follow-redirects/index.js:62:10) at Object.onceWrapper (node:events:628:26) at ClientRequest.emit (node:events:525:35) at ClientRequest.emit (node:domain:489:12) at HTTPParser.parserOnIncomingClient (node:_http_client:693:27) at HTTPParser.parserOnHeadersComplete (node:_http_common:128:17) at TLSSocket.socketOnData (node:_http_client:534:22) at TLSSocket.emit (node:events:513:28) at TLSSocket.emit (node:domain:489:12) at addChunk (node:internal/streams/readable:315:12) at readableAddChunk (node:internal/streams/readable:289:9) at TLSSocket.Readable.push (node:internal/streams/readable:228:10) at TLSWrap.onStreamRead (node:internal/stream_base_commons:190:23)"
}
}
}
I tried creating a set of credentials within n8n the Twitter OAuthAPI (not OAuth2) but am unable to confirm the connection within the “Credentials” screen, it returns an error as follows, presumably because the callback URL for OAuth is https://n8n.mydomain.com/rest/oauth1-credential/callback and not https://n8n.mydomain.com/rest/oauth2-credential/callback (which is the callback in my Twitter Developer console, per the above).
OAuth Authorization Error
There was a problem generating the authorization URL
Request failed with status code 401
So it appears to me that you cannot upload an image using the HTTP request node via the Twitter1.1 API with the Twitter OAuth2 credentials in n8n. As we know, there is not a Twitter API v2 method to upload images, which is why we use the 1.1 API.
I also checked the new Twitter node, and I see that we can attach a media ID to a tweet, but we get that media ID after we upload the image using the HTTP Request node to Twitter via the 1.1 API. Since the upload is failing, I’m not able to get a media ID to attach to the tweet.
Is there something else I need to do to or change to upload images, given the new Twitter OAuth2 credentials?