Skip to content

feat: add email support via confirmed_email field#10

Closed
rossshannon wants to merge 3 commits intounasuke:mainfrom
rossshannon:add-email-support
Closed

feat: add email support via confirmed_email field#10
rossshannon wants to merge 3 commits intounasuke:mainfrom
rossshannon:add-email-support

Conversation

@rossshannon
Copy link
Copy Markdown
Contributor

Summary

This PR adds support for retrieving the user's email address from Twitter/X API v2.

As of April 2025, Twitter/X added the confirmed_email field to their API v2 user endpoint. This PR:

  1. Adds confirmed_email to the user.fields request parameter
  2. Maps confirmed_email to the standard email field in the info hash
  3. Updates the README with documentation on email support

Changes

  • Modified lib/omniauth/strategies/twitter2.rb to request and map confirmed_email
  • Updated README.md with:
    • New "Email Support" section explaining the feature and requirements
    • Updated example scope to include users.email
    • Updated Auth Hash example showing email with a value
    • Added confirmed_email to the raw_info example

Usage

Users need to:

  1. Enable "Request email from users" in their Twitter Developer Portal app settings
  2. Include users.email in their OAuth scope
  3. Handle the case where email may still be nil if the user hasn't confirmed their email

Test plan

  • Tested manually with a Twitter OAuth flow - email is now correctly returned when the scope is granted

Twitter/X added email support to OAuth 2.0 API v2 in April 2025 via the
confirmed_email field. This commit:

- Adds confirmed_email to user.fields in the /2/users/me API request
- Uses confirmed_email in the info hash instead of hardcoding nil

Requires users.email scope to be requested by the application.

See: https://devcommunity.x.com/t/announcing-support-for-email-address-retrieval-with-oauth-2-0-in-the-x-api-v2/240555
Copy link
Copy Markdown
Owner

@unasuke unasuke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thankyou!! I didn't notice that announcement! 😍😍😍😍

Comment thread README.md Outdated
Comment thread README.md Outdated
- Add reference link to X Developer Community announcement
- Revert bullet formatting to use asterisks (*)
- Remove fork-specific installation instructions
@rossshannon rossshannon requested a review from unasuke January 5, 2026 22:35
Comment thread test/omniauth/test_twitter2.rb Outdated
Fix support for Rubies < 3.0

Co-authored-by: Yusuke Nakamura <unasuke@users.noreply.github.com>
@unasuke
Copy link
Copy Markdown
Owner

unasuke commented Jan 6, 2026

@rossshannon Please rebase from the main branch to fix a failed test with the minitest-mock gem. Sorry.

@unasuke
Copy link
Copy Markdown
Owner

unasuke commented Mar 11, 2026

@rossshannon Merged your changes in #13 , thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants