Setting up Twitter OAuth to get the users email address not present
See original GitHub issueProvider type
Environment
System: OS: macOS 12.1 Shell: 5.8 - /bin/zsh Binaries: Node: 14.15.4 - /usr/local/bin/node Yarn: 1.22.10 - /usr/local/bin/yarn npm: 6.14.10 - /usr/local/bin/npm Browsers: Brave Browser: 98.1.35.104 Chrome: 99.0.4844.51 Firefox: 90.0.2 Safari: 15.2 npmPackages: next: ^12.0.10 => 12.0.10 next-auth: ^4.2.1 => 4.2.1 react: ^17.0.2 => 17.0.2
Reproduction URL
https://private.development.site
Describe the issue
When you are setting up OAuth with twitter they have changed the oauth setup, see screen here:
In the above image there is no longer a third tab for the email option but it is now in the box at the bottom.
This image is what you see when you go into the edit on the first image.
The only way to get the optional request to have a users email address is to check 1.0a.
- When doing so with 2.0 checked you do not get the email address.
- Using OAuth 1.0a without the version set in the provider causes it to fail and produce this is the console:
[next-auth][error][GET_AUTHORIZATION_URL_ERROR]
https://next-auth.js.org/errors#get_authorization_url_error undefined {
statusCode: 401,
data: '{"errors":[{"code":32,"message":"Could not authenticate you."}]}'
}
[next-auth][error][SIGNIN_OAUTH_ERROR]
https://next-auth.js.org/errors#signin_oauth_error undefined {
error: {
statusCode: 401,
data: '{"errors":[{"code":32,"message":"Could not authenticate you."}]}'
},
provider: {
id: 'twitter',
name: 'Twitter (Legacy)',
type: 'oauth',
version: '1.0A',
authorization: { url: 'https://api.twitter.com/oauth/authenticate', params: {} },
accessTokenUrl: 'https://api.twitter.com/oauth/access_token',
requestTokenUrl: 'https://api.twitter.com/oauth/request_token',
profileUrl: 'https://api.twitter.com/1.1/account/verify_credentials.json?include_email=true',
profile: [Function: profile],
clientId: 'HIDDEN',
clientSecret: 'HIDDEN',
signinUrl: 'http://localhost:3000/api/auth/signin/twitter',
callbackUrl: 'http://localhost:3000/api/auth/callback/twitter'
},
message: undefined
}
How to reproduce
Create a new nextjs project, use the twitter provider, and try to create an Oauth app with a dev account on twitter.
Expected behavior
It should not throw an error when using v1. It should have a scope option when using v2 to get the email address.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (2 by maintainers)
I ended up finding things like this after I posted but the errors are still a real thing with using v1 with v2 enabled in twitter settings.
Would also be worth updating the screenshots on the docs pages, could do a PR for them if anyone thinks it’s worth the time to add them plus notes that are in the implementation example since it’s not the first place you go to info on usage.
Going to close this issue as it’s a config problem with Twitter. We just got a PR to update the docs as well 🎉