Connecting to Twitter fails with "Unable to get access tokens"

Hello :wave:

I’m trying to connect to Twitter, I followed the guide in the documentation.
Everything seems fine until the last step, after authenticating on Twitter and returning back to n8n on the OAuth Redirect URL (/rest/oauth1-credential/callback) I get the following error:

{"code":0,"message":"Unable to get access tokens!","hint":""}

Any idea on what I’m doing wrong? I can’t seem to find anything via Google or here.

Hey @wesleydv,

What version of n8n are you running and how do you have it configured to run (cloud, docker, reverse proxy)?

Hi @Jon thx for assisting

I’m running 0.141.1

Running the following docker compose config

version: "3"


    image: n8nio/n8n
      - 5678:5678
    restart: always
      - /var/run/docker.sock:/var/run/docker.sock
      - ${DATA_FOLDER}/.n8n:/home/node/.n8n
      - N8N_HOST=[hidden-domain]
      - N8N_PORT=5678
      - N8N_PROTOCOL=https
      - NODE_ENV=production
      - N8N_PATH
      - WEBHOOK_URL=https://[hidden-domain]

This is running behind an nginx reverse proxy with the following config

        listen 443 ssl;
        server_name [hidden-domain];

        include ssl-params.conf;

        ssl_certificate /etc/letsencrypt/live/n8n/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/n8n/privkey.pem;

        access_log /var/log/nginx/n8n_access.log;
        error_log /var/log/nginx/n8n_error.log;

        proxy_buffering off;

        location / {
                proxy_pass http://[hidden-internal-ip]:5678;
                proxy_http_version 1.1;
                proxy_set_header Connection '';
                chunked_transfer_encoding off;
                proxy_buffering off;
                proxy_cache off;


In front of the Nginx I have Cloudflare (tried without same result)

1 Like

It might be worth checking the nginx logs to make sure the callback url is being set correctly in the return so you don’t end up with it using the internal IP instead of the one you are telling it to use.

Checked the logs, nothing in error these are the requests in access - - [01/Oct/2021:22:53:12 +0200] "GET /rest/oauth1-credential/auth?consumerKey=[consumerKey]&consumerSecret=[consumerSecret]& HTTP/1.1" 200 90 "https://[hidden-domain]/workflow" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:92.0) Gecko/20100101 Firefox/92.0" - - [01/Oct/2021:22:53:15 +0200] "GET /rest/push?sessionId=s1pdio0957q HTTP/1.1" 200 19 "https://[hidden-domain]/workflow" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:92.0) Gecko/20100101 Firefox/92.0" - - [01/Oct/2021:22:53:16 +0200] "GET /rest/oauth1-credential/callback?cid=4&oauth_token=[oauth_token]&oauth_verifier=[oauth_verifier] HTTP/1.1" 404 61 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:92.0) Gecko/20100101 Firefox/92.0"

I am out of ideas, I can give mine a check later I am using nginx in front of mine as well so it is almost the same as your setup I have a few more options set for n8n and nginx though.

@harshil1712 do you have any ideas?

Hey @wesleydv,

Welcome to the community :sparkling_heart:

Are you using the Consumer Key and Consumer Secret, or are you using the API Key and Access Token? Also, can you let me know if you’re facing similar issues with other nodes?

Hi @harshil1712

Thanks for taking a look at my case.

I’m using the Consumer key and secret, when I try the Access token and secret I can not even open the authentication Twitter pop-up.
I then get this error

OAuth Authorization Error

Error generating authorization URL:
*401 - "{\"errors\":[{\"message\":\"Could not authenticate you\",\"code\":32}]}\n"*

So I guess Consumer key and secret is the correct one.

Some new info. I tried connecting to other services via OAuth like LinkedIn and Mautic, they all connect fine so must be Twitter specific.

Can you try again but setting the env variable N8N_USE_DEPRECATED_REQUEST_LIB=true

That did the trick :partying_face:
ty @RicardoE105

I actually thought I already tested the N8N_USE_DEPRECATED_REQUEST_LIB before but apparently something else was wrong then. Or maybe the result was cached, not sure.

Glad that it worked. We will let you know when we fix the issue since you should not need the even variable to make it work. Have fun.

1 Like

Hello everyone.

I just tested this with an instance and it worked fine. I was able to connect and perform queries using OAuth authentication on version 0.141.1.

@RicardoE105 can you test locally and see if it works fine for you? I don’t have it set up here. If it does, then maybe it could be something with nginx, although everything seems to be ok and considering it works on version 0.138.0, I hardly doubt so.

hi all,

Any solution to this issue? I have the same problem. My n8n is running on DigitalOcean.

Hey @rtavarez,

How do you have n8n installed and what version are you running? My Twitter node is working as expected here on 150.

Hi all,

@Jon my problem was fixed I was using the wrong Authorization URL in the credentials.


1 Like


I’m getting the same error, but I’m using the OAuth1 credential type to connect to Garmin API.

I’m running n8n 0.152.0 in a VPS with docker (I used the recommended server install with docker compose). I also set N8N_USE_DEPRECATED_REQUEST_LIB to true.

Is there anything I can do to investigate this further?

Thanks for your support!

Hey @lfcipriani

If setting the environment variable does not solve the problem, then I believe the issue you are facing is related to something else.

Probably this is a problem with authentication. Can you double check if all credentials and authentication methods are correct?

Hi @krynble

All the credentials are ok. I created another topic that has more details about my setup.

Thanks for your help.