omniauth-twitter2 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b48323455ad42312548826f0ac3744440d158379a99da8be7eac364dceef0197
4
- data.tar.gz: f6173a09259fb8e82ba02be3061dea0d57c426b749207a0b6d618c522c857047
3
+ metadata.gz: a9a5bf9460fa81e2e1400a60879f0f2c067aed70e32e76733195513a9d2741bf
4
+ data.tar.gz: a74dcf8886af81af0005b972ce6eb349f63e40b3514b7cce02d4b330bb3b38db
5
5
  SHA512:
6
- metadata.gz: 94d5e8d0597b524e9071f5171ddd8dc8dc2476fba13ba4d1d3455f84e839afbda25f58aa78827ed96ed939de6606b832564957bb30e3d5e8cdfcd0e75886bf54
7
- data.tar.gz: c6a2a55f31c2fe8f246593979ead4f429a89f94b36ebd695dea0201429bdb8d8d0c3531ddffedb62a3d8677b201c15369b1ad278f85e905de2bcf7797e1f4d62
6
+ metadata.gz: 04b4f31d5af0fc0a9e2eb38402bf18619b506e6e8989622513f3334215fe0c7d27f5e643d74c7fd34bc2b2f9342f504e528ca3aab3bc2f75f7041c1410276162
7
+ data.tar.gz: b87bb2d9a05795bcfd9f96f7fdef4daa9ee7c53738039f60d6372c7772dd1b1dec54239b1e03045ccaa2e97db418849801ff8707e83653d197e3e409cff46286
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [1.1.0] - 2026-03-12
4
+
5
+ - feat: add email support via confirmed_email field ([#10](https://github.com/unasuke/omniauth-twitter2/pull/10))
6
+
3
7
  ## [1.0.0] - 2025-08-03
4
8
 
5
9
  - Update api endpoints from `twitter.com` to `x.com` ([#7](https://github.com/unasuke/omniauth-twitter2/pull/7))
data/Gemfile CHANGED
@@ -8,3 +8,5 @@ gemspec
8
8
  gem "minitest"
9
9
  gem "rake"
10
10
  gem "rubocop"
11
+
12
+ gem "minitest-mock" if Gem::Version.create(RUBY_VERSION) >= Gem::Version.create("3.1")
data/README.md CHANGED
@@ -1,10 +1,28 @@
1
1
  # OmniAuth::Twitter2
2
+
2
3
  [![test](https://github.com/unasuke/omniauth-twitter2/actions/workflows/main.yml/badge.svg)](https://github.com/unasuke/omniauth-twitter2/actions/workflows/main.yml)
3
4
  [![GitHub license](https://img.shields.io/github/license/unasuke/omniauth-twitter2)](https://github.com/unasuke/omniauth-twitter2/blob/main/LICENSE.txt)
4
5
  [![Gem Version](https://badge.fury.io/rb/omniauth-twitter2.svg)](https://rubygems.org/gems/omniauth-twitter2)
5
6
 
6
7
  This gem provides a OmniAuth strategy for authenticating with Twitter OAuth2.
7
8
 
9
+ ## Email Support
10
+
11
+ As of April 2025, Twitter/X API v2 supports returning the user's email address via the `confirmed_email` field. See the [X Developer Community announcement](https://devcommunity.x.com/t/introducing-confirmed-email-in-user-object/233461).
12
+
13
+ To request the email, include the `users.email` scope:
14
+
15
+ ```ruby
16
+ scope: "tweet.read users.read users.email"
17
+ ```
18
+
19
+ **Note:** The email will only be returned if:
20
+
21
+ 1. Your Twitter app has "Request email from users" enabled in the Developer Portal
22
+ 2. The user has a confirmed email address on their Twitter account
23
+ 3. The user grants permission during OAuth
24
+
25
+ If these conditions aren't met, `email` will be `nil` in the auth hash.
8
26
 
9
27
  ## Installation
10
28
 
@@ -33,7 +51,7 @@ $ gem install omniauth-twitter2
33
51
  ```ruby
34
52
  # config/initializers/omniauth.rb
35
53
  Rails.application.config.middleware.use OmniAuth::Builder do
36
- provider :twitter2, ENV["TWITTER_CLIENT_ID"], ENV["TWITTER_CLIENT_SECRET"], callback_path: '/auth/twitter2/callback', scope: "tweet.read users.read"
54
+ provider :twitter2, ENV["TWITTER_CLIENT_ID"], ENV["TWITTER_CLIENT_SECRET"], callback_path: '/auth/twitter2/callback', scope: "tweet.read users.read users.email"
37
55
  end
38
56
  ```
39
57
 
@@ -44,7 +62,7 @@ end
44
62
  "uid" => "108252390",
45
63
  "info" => {
46
64
  "name" => "うなすけ",
47
- "email" => nil,
65
+ "email" => "user@example.com", # nil if users.email scope not granted or email not confirmed
48
66
  "nickname" => "yu_suke1994",
49
67
  "description" => "帰って寝たい",
50
68
  "image" => "https://pbs.twimg.com/profile_images/580019517608218624/KzEZSzUy_normal.jpg",
@@ -61,6 +79,7 @@ end
61
79
  "extra" => {
62
80
  "raw_info" => {
63
81
  "data" => {
82
+ "confirmed_email" => "user@example.com", # only present if users.email scope granted
64
83
  "profile_image_url" => "https://pbs.twimg.com/profile_images/580019517608218624/KzEZSzUy_normal.jpg",
65
84
  "url" => "https://t.co/NCFLB8wDkx",
66
85
  "public_metrics" => {
@@ -108,6 +127,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
108
127
  * [nov/twitter_oauth2: Twitter OAuth 2.0 Client Library in Ruby](https://github.com/nov/twitter_oauth2)
109
128
 
110
129
  ## Sample App
130
+
111
131
  * <https://twitter-login-app.onrender.com/>
112
132
  * <https://github.com/unasuke/twitter-login-app>
113
133
 
@@ -20,7 +20,7 @@ module OmniAuth
20
20
  info do
21
21
  {
22
22
  name: raw_info["data"]["name"],
23
- email: nil,
23
+ email: raw_info["data"]["confirmed_email"],
24
24
  nickname: raw_info["data"]["username"],
25
25
  description: raw_info["data"]["description"],
26
26
  image: raw_info["data"]["profile_image_url"],
@@ -38,7 +38,7 @@ module OmniAuth
38
38
  def raw_info
39
39
  @raw_info ||= access_token.get(
40
40
  "/2/users/me?" \
41
- "&user.fields=created_at,description,entities,id,location,name,pinned_tweet_id," \
41
+ "user.fields=confirmed_email,created_at,description,entities,id,location,name,pinned_tweet_id," \
42
42
  "profile_image_url,protected,public_metrics,url,username,verified,withheld",
43
43
  { headers: { "Authorization" => "Bearer #{access_token.token}" } }
44
44
  ).parsed || {}
@@ -2,6 +2,6 @@
2
2
 
3
3
  module OmniAuth
4
4
  module Twitter2
5
- VERSION = "1.0.0"
5
+ VERSION = "1.1.0"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-twitter2
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yusuke Nakamura
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-08-02 00:00:00.000000000 Z
10
+ date: 2026-03-11 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: omniauth