[GH-ISSUE #423] Twitter / X social provider not working #16897

Closed
opened 2026-04-15 14:52:20 -05:00 by GiteaMirror · 0 comments
Owner

Originally created by @dpuscher on GitHub (Nov 5, 2024).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/423

Describe the bug
Currently the Twitter / X login is not working. Problem seems to be that the scope is wrong. The passed url contains: scope=account_info.read

My research shows that account_info.read is not a valid scope. offline.access seems to work, but if I manually patch this into the better-auth package, Twitter fails to correctly redirect to the app, because the state in the url is broken:

 ERROR   Expected property name or '}' in JSON at position 1
  at JSON.parse (<anonymous>)
  at H (node_modules/better-auth/dist/chunk-MIF2W335.js:1:2343)

The paramaters in the callback url are as follows (decoded and codes shortened):

state: {code:K6R[...]1RgcallbackURL:http://localhost:4321}
code: UXR[...]OjE

To Reproduce
Steps to reproduce the behavior:

  1. Add the twitter social provider to the config
  2. Call authClient.signIn.social({ provider: "twitter" })
  3. The twitter logins fails with "Something went wrong".

Expected behavior
The login is working correctly.

Screenshots
twitter com_i_oauth2

Originally created by @dpuscher on GitHub (Nov 5, 2024). Original GitHub issue: https://github.com/better-auth/better-auth/issues/423 **Describe the bug** Currently the Twitter / X login is not working. Problem seems to be that the scope is wrong. The passed url contains: `scope=account_info.read` My research shows that `account_info.read` is not a valid scope. `offline.access` seems to work, but if I manually patch this into the better-auth package, Twitter fails to correctly redirect to the app, because the state in the url is broken: ```bash ERROR Expected property name or '}' in JSON at position 1 at JSON.parse (<anonymous>) at H (node_modules/better-auth/dist/chunk-MIF2W335.js:1:2343) ``` The paramaters in the callback url are as follows (decoded and codes shortened): ``` state: {code:K6R[...]1RgcallbackURL:http://localhost:4321} code: UXR[...]OjE ``` **To Reproduce** Steps to reproduce the behavior: 1. Add the `twitter` social provider to the config 2. Call `authClient.signIn.social({ provider: "twitter" })` 3. The twitter logins fails with "Something went wrong". **Expected behavior** The login is working correctly. **Screenshots** ![twitter com_i_oauth2](https://github.com/user-attachments/assets/5a967ed9-f153-4a18-830b-984af396eb3b)
GiteaMirror added the locked label 2026-04-15 14:52:20 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#16897