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.

Setting up Twitter OAuth to get the users email address not present

See original GitHub issue

Provider type

Twitter

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:

Screen Shot 2022-03-16 at 9 10 53 AM

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.

Screen Shot 2022-03-16 at 9 11 08 AM

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:closed
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
dcantatorecommented, Mar 18, 2022

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.

0reactions
ndom91commented, May 17, 2022

Going to close this issue as it’s a config problem with Twitter. We just got a PR to update the docs as well 🎉

Read more comments on GitHub >

github_iconTop Results From Across the Web

GET account/verify_credentials | Docs - Twitter Developer
Request a User's Email Address¶. The "Request email addresses from users" checkbox is available under the app permissions on developer.twitter.com. Privacy ...
Read more >
Where's "Request email addresses from users" checkbox?
Click on “Edit” button under “User authentication settings” section. Then under “OAUTH 1.0A SETTINGS” section there is a checkbox named " Request email...
Read more >
Is there a way to get an user's email ID after verifying his/her ...
I am able to fetch the credentials of an user after authentication by making a request to http://api.twitter.com/1/account/verify_credentials.
Read more >
Not able to get email in Twitter OAuth response - Google Groups
After Twitter oks the request, you should go to you app settings and select the option to add the email scope. This is...
Read more >
Twitter OAuth - Part 26 - YouTube
... how to use Twitter OAuth to login in users.Code: https://github.com/benawad/graphql-ts-server-boilerplate/tree/27_twitter_oauthPlaylist: ...
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