Issue connecting X to n8n, continuous log in loop

Issue Connecting X to N8N

Running into an pretty frustrating issue when attempting to connect X to n8n in my workflow. After adding the correct callback URL on https://console.x.com and adding the Client ID and Client Secret to the credentials section in n8n, I then choose “Connect to X”. This populates the below pop up window. I choose log in and enter my user / password and select log in. I’m then routed back to this exact same page again. The callback URL is exactly the same, I’ve cleared cache and have attempted on both Chrome and Firefox as well as in incognito windows. Nothing appears to fix this.

Hi @Trigg_Williamson

You are experiencing a “login loop,” which happens when X (Twitter) fails to recognize your session after you log in, sending you right back to the start instead of letting you authorize n8n. This is usually caused by a communication glitch between the two platforms or a small setting error in your developer account.

The quickest fix is to log into X in a separate browser tab before trying to connect. By opening x.com and logging in normally first, your browser keeps an active session. When you then go back to n8n and click “Connect,” X should see that you are already logged in and skip the login screen entirely, taking you straight to the authorization page.

If that doesn’t work, the problem might be how your app is categorized in the X Developer Portal. Under your “User authentication settings,” try changing the “App type.” If it is set to “Web App,” try switching it to “Native App” (or vice versa). For some reason, X handles the login handoff differently depending on this setting, and switching it often breaks the loop.

You should also double-check that your technical settings are perfect. Ensure your app permissions are set to “Read and Write” rather than just “Read.” Most importantly, make sure the Callback URL in the X portal is a perfect copy-paste of the one provided by n8n. Even a tiny difference, like an extra slash at the end, can cause X to reject the connection and loop you back to the login screen.

Finally, check your browser extensions. Ad-blockers or privacy tools (like uBlock Origin or Brave’s shields) often block the “security tokens” that X sends back to n8n to prove who you are. Try disabling these extensions or using a completely clean browser window to ensure nothing is interfering with the redirect process.

Thanks for your insightful reply @kjooleng Unfortunately after trying all of these, I’m still running into the same issue.

Is there anything else you’d suggest?

I’m using n8n cloud. I went through and tried to do this but it appears to be running into the same issue.

hi @Trigg_Williamson welcome to the n8n community
could you please share the json without the sensitive data? use the “</>” option when pasting it here

Welcome @Trigg_Williamson! Since you’re on n8n Cloud, the exact callback URL you need to register in X Developer Portal is https://oauth.n8n.cloud/oauth2/callback - make sure that’s added under the “Redirect URIs” in your X App settings. Also double-check that your X App’s “Type of App” is set to “Web App, Automated App or Bot” (not Native App), since PKCE flow requires that. If you already have the right callback URL and App type set but still get the loop, try revoking the existing X token in the X app settings and reconnecting fresh.

So the callback URL should not be what is presented in the credential creation page on n8n → https://oauth.n8n.cloud/oauth2/callback ?

@Trigg_Williamson
I reproduced your case and found these 3 issues:

  • In the X Developer Portal, the app wasn’t configured as a Web App in User authentication settings, or the Callback URI wasn’t exactly https://oauth.n8n.cloud/oauth2/callback
  • The access_type=offline parameter in Auth URI Query Parameters is from Google, not from X - removing it resolved the issue.
  • The scopes media.write and offline.access may require a paid tier on X API v2; try first with tweet.read tweet.write users.read

Please, after fixing the Developer Portal, delete and recreate the credential in n8n (not just reconnect) and then test in an incognito window to eliminate any X session cookie conflict.

Please let us know if it worked :crossed_fingers:

Thanks Tamy, unfortunately this did not appear to work. The Callback URL is exactly the same. Other fixes did not change anything either.

@Trigg_Williamson, please share your JSON.
There’s something odd…

When you add X/Twitter credentials in n8n, there are usually options for both X OAuth1 and X OAuth2.

The settings you configured are strictly for OAuth 2.0.

Make sure that inside your n8n credential setup window, you have explicitly chosen OAuth2 as the authentication method. If n8n is expecting an OAuth 1.0a credential but you are feeding it OAuth 2.0 keys, X will just refresh the login page forever without passing the token.

Check if this solution works, you can also enable OAuth 1.0a on X as the backup fix.

Hope it works!

I have the same issue, I tried everything listed here and more. It’s driving me crazy. OAuth1 works fine. OAuth2 doesn’t. I think it used to work in a older n8n version because I was able to create an X OAuth2 credential months ago and nothing changed on my side, same server, same X accounts, same X App.

I may have found a solution. Logged in on x.com with the X account I want to connect to n8n. Opened n8n credential page in another tab. When the popup window appears after clicking “connect”, I copied the url, opened it in a note (because I couldnt edit it in the address bar) changed “twitter.com” to “x.com” and kept the rest of the url the same. Then opened the modified url in another tab, authorized the app and the connection was successful on n8n.
I’m not sure if the issue was caused by some third-party cookie block (despite having allowed them browser wide) or just by the fact that n8n opens twitter.com instead of x.com