omniauth-twitter2 0.1.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: f46f460692cde04fdefa508e5ee2393ba6aa4e330987ea760c3cf9671c6015c6
4
- data.tar.gz: 83e8e366704f172d37c5d5dc005f4bcdbb1fb6f9d71b2ee79eac558e62cf9bd5
3
+ metadata.gz: a9a5bf9460fa81e2e1400a60879f0f2c067aed70e32e76733195513a9d2741bf
4
+ data.tar.gz: a74dcf8886af81af0005b972ce6eb349f63e40b3514b7cce02d4b330bb3b38db
5
5
  SHA512:
6
- metadata.gz: 280543b64cbeccc177c4bbecb9714b84d63e97da6abdd864cedcb90c6be6e147aeb6ad3847409a6a8c67456794270fa6e2e04b73b14c7425636805ca6eb44e02
7
- data.tar.gz: b634f91a0b28fc6d3bf1d5da2d2a78101bf5da8a070691da193c59c51d038cadb7fe172c603273ab08ae07f63b03fb987e8fbf8d8e8f175024965592e5967fc7
6
+ metadata.gz: 04b4f31d5af0fc0a9e2eb38402bf18619b506e6e8989622513f3334215fe0c7d27f5e643d74c7fd34bc2b2f9342f504e528ca3aab3bc2f75f7041c1410276162
7
+ data.tar.gz: b87bb2d9a05795bcfd9f96f7fdef4daa9ee7c53738039f60d6372c7772dd1b1dec54239b1e03045ccaa2e97db418849801ff8707e83653d197e3e409cff46286
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.4.1
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  ## [Unreleased]
2
2
 
3
- ## [0.1.0] - 2022-01-10
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
+
7
+ ## [1.0.0] - 2025-08-03
8
+
9
+ - Update api endpoints from `twitter.com` to `x.com` ([#7](https://github.com/unasuke/omniauth-twitter2/pull/7))
10
+
11
+ ## [0.1.0] - 2022-01-13
4
12
 
5
13
  - Initial release
data/Gemfile CHANGED
@@ -5,8 +5,8 @@ source "https://rubygems.org"
5
5
  # Specify your gem's dependencies in omniauth-twitter2.gemspec
6
6
  gemspec
7
7
 
8
- gem "rake", "~> 13.0"
8
+ gem "minitest"
9
+ gem "rake"
10
+ gem "rubocop"
9
11
 
10
- gem "minitest", "~> 5.0"
11
-
12
- gem "rubocop", "~> 1.21"
12
+ gem "minitest-mock" if Gem::Version.create(RUBY_VERSION) >= Gem::Version.create("3.1")
data/README.md CHANGED
@@ -1,7 +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)
4
+ [![GitHub license](https://img.shields.io/github/license/unasuke/omniauth-twitter2)](https://github.com/unasuke/omniauth-twitter2/blob/main/LICENSE.txt)
5
+ [![Gem Version](https://badge.fury.io/rb/omniauth-twitter2.svg)](https://rubygems.org/gems/omniauth-twitter2)
6
+
3
7
  This gem provides a OmniAuth strategy for authenticating with Twitter OAuth2.
4
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.
5
26
 
6
27
  ## Installation
7
28
 
@@ -30,7 +51,7 @@ $ gem install omniauth-twitter2
30
51
  ```ruby
31
52
  # config/initializers/omniauth.rb
32
53
  Rails.application.config.middleware.use OmniAuth::Builder do
33
- provider :twitter2, ENV["TWITTER_API_KEY"], ENV["TWITTER_API_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"
34
55
  end
35
56
  ```
36
57
 
@@ -41,13 +62,13 @@ end
41
62
  "uid" => "108252390",
42
63
  "info" => {
43
64
  "name" => "うなすけ",
44
- "email" => nil,
65
+ "email" => "user@example.com", # nil if users.email scope not granted or email not confirmed
45
66
  "nickname" => "yu_suke1994",
46
67
  "description" => "帰って寝たい",
47
68
  "image" => "https://pbs.twimg.com/profile_images/580019517608218624/KzEZSzUy_normal.jpg",
48
69
  "urls" => {
49
70
  "Website" => "https://t.co/NCFLB8wDkx",
50
- "Twitter" => "https://twitter.com/yu_suke1994"
71
+ "Twitter" => "https://x.com/yu_suke1994"
51
72
  }
52
73
  },
53
74
  "credentials" => {
@@ -58,6 +79,7 @@ end
58
79
  "extra" => {
59
80
  "raw_info" => {
60
81
  "data" => {
82
+ "confirmed_email" => "user@example.com", # only present if users.email scope granted
61
83
  "profile_image_url" => "https://pbs.twimg.com/profile_images/580019517608218624/KzEZSzUy_normal.jpg",
62
84
  "url" => "https://t.co/NCFLB8wDkx",
63
85
  "public_metrics" => {
@@ -98,12 +120,17 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
98
120
  ## References
99
121
 
100
122
  * Twitter official resources
101
- * [twitterdev/Twitter-API-v2-sample-code: Sample code for the Twitter API v2 endpoints](https://github.com/twitterdev/Twitter-API-v2-sample-code)
102
- * [OAuth 2.0 Making requests on behalf of users | Docs | Twitter Developer Platform](https://developer.twitter.com/en/docs/authentication/oauth-2-0/user-access-token)
123
+ * [xdevplatform/Twitter-API-v2-sample-code: Sample code for the Twitter API v2 endpoints](https://github.com/xdevplatform/Twitter-API-v2-sample-code)
124
+ * [OAuth 2.0 - X](https://docs.x.com/fundamentals/authentication/oauth-2-0/overview)
103
125
  * [arunagw/omniauth-twitter: OmniAuth strategy for Twitter](https://github.com/arunagw/omniauth-twitter)
104
126
  * [omniauth/omniauth-oauth2: An abstract OAuth2 strategy for OmniAuth.](https://github.com/omniauth/omniauth-oauth2)
105
127
  * [nov/twitter_oauth2: Twitter OAuth 2.0 Client Library in Ruby](https://github.com/nov/twitter_oauth2)
106
128
 
129
+ ## Sample App
130
+
131
+ * <https://twitter-login-app.onrender.com/>
132
+ * <https://github.com/unasuke/twitter-login-app>
133
+
107
134
  ## Contributing
108
135
 
109
136
  Bug reports and pull requests are welcome on GitHub at https://github.com/unasuke/omniauth-twitter2. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/unasuke/omniauth-twitter2/blob/main/CODE_OF_CONDUCT.md).
@@ -7,10 +7,11 @@ module OmniAuth
7
7
  module Strategies
8
8
  class Twitter2 < OmniAuth::Strategies::OAuth2 # :nodoc:
9
9
  option :name, "twitter2"
10
+ # https://docs.x.com/fundamentals/authentication/oauth-2-0/overview
10
11
  option :client_options, {
11
- site: "https://api.twitter.com",
12
+ site: "https://api.x.com",
12
13
  token_url: "2/oauth2/token",
13
- authorize_url: "https://twitter.com/i/oauth2/authorize"
14
+ authorize_url: "https://x.com/i/oauth2/authorize"
14
15
  }
15
16
  option :pkce, true
16
17
 
@@ -19,13 +20,13 @@ module OmniAuth
19
20
  info do
20
21
  {
21
22
  name: raw_info["data"]["name"],
22
- email: nil,
23
+ email: raw_info["data"]["confirmed_email"],
23
24
  nickname: raw_info["data"]["username"],
24
25
  description: raw_info["data"]["description"],
25
26
  image: raw_info["data"]["profile_image_url"],
26
27
  urls: {
27
28
  Website: raw_info["data"]["url"],
28
- Twitter: "https://twitter.com/#{raw_info["data"]["username"]}"
29
+ Twitter: "https://x.com/#{raw_info["data"]["username"]}"
29
30
  }
30
31
  }
31
32
  end
@@ -37,7 +38,7 @@ module OmniAuth
37
38
  def raw_info
38
39
  @raw_info ||= access_token.get(
39
40
  "/2/users/me?" \
40
- "&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," \
41
42
  "profile_image_url,protected,public_metrics,url,username,verified,withheld",
42
43
  { headers: { "Authorization" => "Bearer #{access_token.token}" } }
43
44
  ).parsed || {}
@@ -2,6 +2,6 @@
2
2
 
3
3
  module OmniAuth
4
4
  module Twitter2
5
- VERSION = "0.1.0"
5
+ VERSION = "1.1.0"
6
6
  end
7
7
  end
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
16
16
 
17
17
  spec.metadata["homepage_uri"] = spec.homepage
18
18
  spec.metadata["source_code_uri"] = spec.homepage
19
- # spec.metadata["changelog_uri"] = "TBA"
19
+ spec.metadata["changelog_uri"] = "https://github.com/unasuke/omniauth-twitter2/blob/main/CHANGELOG.md"
20
20
  spec.metadata["rubygems_mfa_required"] = "true"
21
21
 
22
22
  # Specify which files should be added to the gem when it is released.
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-twitter2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yusuke Nakamura
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2022-01-13 00:00:00.000000000 Z
10
+ date: 2026-03-11 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: omniauth
@@ -46,10 +45,10 @@ extensions: []
46
45
  extra_rdoc_files: []
47
46
  files:
48
47
  - ".rubocop.yml"
48
+ - ".ruby-version"
49
49
  - CHANGELOG.md
50
50
  - CODE_OF_CONDUCT.md
51
51
  - Gemfile
52
- - Gemfile.lock
53
52
  - LICENSE.txt
54
53
  - README.md
55
54
  - Rakefile
@@ -66,8 +65,8 @@ licenses:
66
65
  metadata:
67
66
  homepage_uri: https://github.com/unasuke/omniauth-twitter2
68
67
  source_code_uri: https://github.com/unasuke/omniauth-twitter2
68
+ changelog_uri: https://github.com/unasuke/omniauth-twitter2/blob/main/CHANGELOG.md
69
69
  rubygems_mfa_required: 'true'
70
- post_install_message:
71
70
  rdoc_options: []
72
71
  require_paths:
73
72
  - lib
@@ -82,8 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
82
81
  - !ruby/object:Gem::Version
83
82
  version: '0'
84
83
  requirements: []
85
- rubygems_version: 3.2.22
86
- signing_key:
84
+ rubygems_version: 3.6.2
87
85
  specification_version: 4
88
86
  summary: Twitter OAuth2 strategy for OmniAuth
89
87
  test_files: []
data/Gemfile.lock DELETED
@@ -1,89 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- omniauth-twitter2 (0.1.0)
5
- omniauth
6
- omniauth-oauth2 (~> 1.0)
7
-
8
- GEM
9
- remote: https://rubygems.org/
10
- specs:
11
- ast (2.4.2)
12
- faraday (1.9.3)
13
- faraday-em_http (~> 1.0)
14
- faraday-em_synchrony (~> 1.0)
15
- faraday-excon (~> 1.1)
16
- faraday-httpclient (~> 1.0)
17
- faraday-multipart (~> 1.0)
18
- faraday-net_http (~> 1.0)
19
- faraday-net_http_persistent (~> 1.0)
20
- faraday-patron (~> 1.0)
21
- faraday-rack (~> 1.0)
22
- faraday-retry (~> 1.0)
23
- ruby2_keywords (>= 0.0.4)
24
- faraday-em_http (1.0.0)
25
- faraday-em_synchrony (1.0.0)
26
- faraday-excon (1.1.0)
27
- faraday-httpclient (1.0.1)
28
- faraday-multipart (1.0.3)
29
- multipart-post (>= 1.2, < 3)
30
- faraday-net_http (1.0.1)
31
- faraday-net_http_persistent (1.2.0)
32
- faraday-patron (1.0.0)
33
- faraday-rack (1.0.0)
34
- faraday-retry (1.0.3)
35
- hashie (5.0.0)
36
- jwt (2.3.0)
37
- minitest (5.15.0)
38
- multi_json (1.15.0)
39
- multi_xml (0.6.0)
40
- multipart-post (2.1.1)
41
- oauth2 (1.4.7)
42
- faraday (>= 0.8, < 2.0)
43
- jwt (>= 1.0, < 3.0)
44
- multi_json (~> 1.3)
45
- multi_xml (~> 0.5)
46
- rack (>= 1.2, < 3)
47
- omniauth (2.0.4)
48
- hashie (>= 3.4.6)
49
- rack (>= 1.6.2, < 3)
50
- rack-protection
51
- omniauth-oauth2 (1.7.2)
52
- oauth2 (~> 1.4)
53
- omniauth (>= 1.9, < 3)
54
- parallel (1.21.0)
55
- parser (3.1.0.0)
56
- ast (~> 2.4.1)
57
- rack (2.2.3)
58
- rack-protection (2.1.0)
59
- rack
60
- rainbow (3.0.0)
61
- rake (13.0.6)
62
- regexp_parser (2.2.0)
63
- rexml (3.2.5)
64
- rubocop (1.24.1)
65
- parallel (~> 1.10)
66
- parser (>= 3.0.0.0)
67
- rainbow (>= 2.2.2, < 4.0)
68
- regexp_parser (>= 1.8, < 3.0)
69
- rexml
70
- rubocop-ast (>= 1.15.1, < 2.0)
71
- ruby-progressbar (~> 1.7)
72
- unicode-display_width (>= 1.4.0, < 3.0)
73
- rubocop-ast (1.15.1)
74
- parser (>= 3.0.1.1)
75
- ruby-progressbar (1.11.0)
76
- ruby2_keywords (0.0.5)
77
- unicode-display_width (2.1.0)
78
-
79
- PLATFORMS
80
- x86_64-linux
81
-
82
- DEPENDENCIES
83
- minitest (~> 5.0)
84
- omniauth-twitter2!
85
- rake (~> 13.0)
86
- rubocop (~> 1.21)
87
-
88
- BUNDLED WITH
89
- 2.3.4