Not able to authenticate via NextAuth's Twitter provider using OAuth2.0
See original GitHub issueEnvironment
System: OS: Linux 5.4 Ubuntu 20.04.2 LTS (Focal Fossa) CPU: (8) x64 Intel® Core™ i7-10610U CPU @ 1.80GHz Memory: 17.85 GB / 24.75 GB Container: Yes Shell: 5.0.17 - /bin/bash Binaries: Node: 16.0.0 - ~/.nvm/versions/node/v16.0.0/bin/node Yarn: 1.22.10 - ~/.nvm/versions/node/v16.0.0/bin/yarn npm: 7.10.0 - ~/.nvm/versions/node/v16.0.0/bin/npm Browsers: Chrome: 100.0.4896.127 npmPackages: next: 12.2.5 => 12.2.5 next-auth: ^4.10.3 => 4.10.3 react: 18.2.0 => 18.2.0
Reproduction URL
it’s a localhost url
Describe the issue
Hi there,
I am having a hard time getting nextauth to authenticate via OAUth2 using the twitter provider. Upon clicking on “sign in with twitter” I am presented with an error saying “something is wrong”. Screenshot attached:
Also, the below gets reported in console logs:
ondemand.BranchSdk.62484ce8.js:1 GET https://app.link/_r?sdk=web2.56.2&branch_key=key_live_knJAF6W45vSHVJiP0wn8figpqFePX59K&callback=branch_callback__2 net::ERR_BLOCKED_BY_CLIENT
I have ensured the redirect uri in twitter’s developer profile is not the localhost url but something like https://127.0.0.1:3000/api/auth…
Below is how I have the provider defined in next
import NextAuth from "next-auth/next";
import TwitterProvider from "next-auth/providers/twitter";
export default NextAuth({
// Configure one or more authentication providers
providers: [
TwitterProvider({
clientId: process.env.TWITTER_ID,
clientSecret: process.env.TWITTER_SECRET,
version: "2.0",
}),
// ...add more providers here
],
})
I am not sure what I am doing wrong. Is it the redirect uri? Any pointers would be of immense help,
Thank you!
How to reproduce
It’s a std next project with nextauth configured to authenticate via oauth2. Click on sign in via twitter and most likely you’d see this error.
Expected behavior
First it would request my permission to allow access to the app and eventually it should have authenticated me and signed me up.
Issue Analytics
- State:
- Created a year ago
- Reactions:5
- Comments:10 (3 by maintainers)
same issue for me, i’m using NextAuth in several other projects ( not with Twitter), but here just don’t work…
It seems like the call URL isn’t fired, in fact if click the “back” button ( same screenshot as above) it brings me to the Twitter homepage, not my localhost
I’m having this issue right now. I am using the 2.0 client ID and Client Secret but get the something went wrong screen.
I’m using http://127.0.0.1:5173/ as the callback url