question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Not able to authenticate via NextAuth's Twitter provider using OAuth2.0

See original GitHub issue

Environment

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:

image

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:open
  • Created a year ago
  • Reactions:5
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
CRSylarcommented, Nov 20, 2022

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

0reactions
mikhail-karancommented, Dec 15, 2022

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Authenticate Next.js Apps with Twitter & NextAuth.js
js, set up and configure a Twitter app, and use Twitter as a Provider for authenticating visitors to our app.
Read more >
Twitter | NextAuth.js
Twitter is currently the only built-in provider using the OAuth 1.0 spec. This means that you won't receive an accesstoken or refreshtoken, ...
Read more >
OAuth 2.0 Authorization Code Flow with PKCE | Docs
With OAuth 2.0, you create an authorize URL, which you can use to allow a user to authenticate via an authentication flow, similar...
Read more >
Next.js Authentication with Twitter & NextAuth.js - YouTube
Learn how to add Twitter login authentication to a Next.js app with NextAuth.js. What's Inside0:00 - Intro to Next.js Authentication with...
Read more >
Next-Auth.js problem with Twitter Authorization
This error means that you didn't give your app permission. Make use of your Twitter APIKEY and API SECRET provided by Twitter on...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found