omniauth-twitter2 1.0.0 → 1.2.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 +4 -4
- data/CHANGELOG.md +13 -0
- data/Gemfile +2 -0
- data/README.md +25 -5
- data/lib/omniauth/strategies/twitter2.rb +24 -3
- data/lib/omniauth/twitter2/version.rb +1 -1
- data/omniauth-twitter2.gemspec +3 -2
- metadata +6 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 75f14cedc7faaf00d30e11994f7d0a7d1ab62ce8a337165afe75f3274983d683
|
|
4
|
+
data.tar.gz: 21c3beb41bb76eaaa0ec558c5fe43d8973d4d23249e1934f786ec092aa0bbd0d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1bbb69083b4e90d6691d0aa545733a1a1c63fc6cf0152a621a031bf9b8812d307911f9399d15c8f9418e2fd1970ccbf888952496d1fac10b7a208da329945dd9
|
|
7
|
+
data.tar.gz: 740e6eeaa3c485d3853261eaec50949ee045ec937258947d38ae87a4d02bb8a7a47cc2373d6ec84a54907cb328684603e0f0c1945ba7b61dbf7a4b81f0dd83ed
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
+
## [1.2.0] - 2026-05-22
|
|
4
|
+
|
|
5
|
+
- fix: avoid requesting `confirmed_email` without `users.email` scope ([#17](https://github.com/unasuke/omniauth-twitter2/pull/17))
|
|
6
|
+
- chore: replace Twitter branding with X in documentation and gem metadata ([#16](https://github.com/unasuke/omniauth-twitter2/pull/16))
|
|
7
|
+
- chore: add release workflow for trusted publishing ([#19](https://github.com/unasuke/omniauth-twitter2/pull/19))
|
|
8
|
+
- chore: pin GitHub Actions by hash and switch dependabot to monthly schedule ([#18](https://github.com/unasuke/omniauth-twitter2/pull/18))
|
|
9
|
+
- chore: bump actions/checkout from 4 to 6 ([#15](https://github.com/unasuke/omniauth-twitter2/pull/15))
|
|
10
|
+
- chore: add Dependabot config for GitHub Actions updates ([#14](https://github.com/unasuke/omniauth-twitter2/pull/14))
|
|
11
|
+
|
|
12
|
+
## [1.1.0] - 2026-03-12
|
|
13
|
+
|
|
14
|
+
- feat: add email support via confirmed_email field ([#10](https://github.com/unasuke/omniauth-twitter2/pull/10))
|
|
15
|
+
|
|
3
16
|
## [1.0.0] - 2025-08-03
|
|
4
17
|
|
|
5
18
|
- Update api endpoints from `twitter.com` to `x.com` ([#7](https://github.com/unasuke/omniauth-twitter2/pull/7))
|
data/Gemfile
CHANGED
data/README.md
CHANGED
|
@@ -1,10 +1,28 @@
|
|
|
1
1
|
# OmniAuth::Twitter2
|
|
2
|
+
|
|
2
3
|
[](https://github.com/unasuke/omniauth-twitter2/actions/workflows/main.yml)
|
|
3
4
|
[](https://github.com/unasuke/omniauth-twitter2/blob/main/LICENSE.txt)
|
|
4
5
|
[](https://rubygems.org/gems/omniauth-twitter2)
|
|
5
6
|
|
|
6
|
-
This gem provides a OmniAuth strategy for authenticating with Twitter OAuth2.
|
|
7
|
+
This gem provides a OmniAuth strategy for authenticating with X (formerly known as Twitter) OAuth2.
|
|
8
|
+
|
|
9
|
+
## Email Support
|
|
10
|
+
|
|
11
|
+
As of April 2025, 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:
|
|
7
20
|
|
|
21
|
+
1. Your X app has "Request email from users" enabled in the Developer Portal
|
|
22
|
+
2. The user has a confirmed email address on their X 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" => {
|
|
@@ -100,14 +119,15 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
|
100
119
|
|
|
101
120
|
## References
|
|
102
121
|
|
|
103
|
-
*
|
|
104
|
-
* [xdevplatform/
|
|
122
|
+
* X official resources
|
|
123
|
+
* [xdevplatform/samples: Sample code for the X API v2 endpoints](https://github.com/xdevplatform/samples)
|
|
105
124
|
* [OAuth 2.0 - X](https://docs.x.com/fundamentals/authentication/oauth-2-0/overview)
|
|
106
125
|
* [arunagw/omniauth-twitter: OmniAuth strategy for Twitter](https://github.com/arunagw/omniauth-twitter)
|
|
107
126
|
* [omniauth/omniauth-oauth2: An abstract OAuth2 strategy for OmniAuth.](https://github.com/omniauth/omniauth-oauth2)
|
|
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:
|
|
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,8 +38,7 @@ module OmniAuth
|
|
|
38
38
|
def raw_info
|
|
39
39
|
@raw_info ||= access_token.get(
|
|
40
40
|
"/2/users/me?" \
|
|
41
|
-
"
|
|
42
|
-
"profile_image_url,protected,public_metrics,url,username,verified,withheld",
|
|
41
|
+
"user.fields=#{build_user_fields_query}",
|
|
43
42
|
{ headers: { "Authorization" => "Bearer #{access_token.token}" } }
|
|
44
43
|
).parsed || {}
|
|
45
44
|
end
|
|
@@ -59,6 +58,28 @@ module OmniAuth
|
|
|
59
58
|
)
|
|
60
59
|
super
|
|
61
60
|
end
|
|
61
|
+
|
|
62
|
+
private
|
|
63
|
+
|
|
64
|
+
def build_user_fields_query
|
|
65
|
+
if users_email_required?
|
|
66
|
+
user_fields_query_base.push("confirmed_email")
|
|
67
|
+
else
|
|
68
|
+
user_fields_query_base
|
|
69
|
+
end
|
|
70
|
+
.join(",")
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def user_fields_query_base
|
|
74
|
+
%w[
|
|
75
|
+
created_at description entities id location name pinned_tweet_id
|
|
76
|
+
profile_image_url protected public_metrics url username verified withheld
|
|
77
|
+
]
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def users_email_required?
|
|
81
|
+
options[:scope].split(/\s+/).include?("users.email")
|
|
82
|
+
end
|
|
62
83
|
end
|
|
63
84
|
end
|
|
64
85
|
end
|
data/omniauth-twitter2.gemspec
CHANGED
|
@@ -8,8 +8,9 @@ Gem::Specification.new do |spec|
|
|
|
8
8
|
spec.authors = ["Yusuke Nakamura"]
|
|
9
9
|
spec.email = ["yusuke1994525@gmail.com"]
|
|
10
10
|
|
|
11
|
-
spec.summary = "Twitter OAuth2 strategy for OmniAuth"
|
|
12
|
-
spec.description = "Twitter OAuth2 strategy for OmniAuth.
|
|
11
|
+
spec.summary = "X (formerly known as Twitter) OAuth2 strategy for OmniAuth"
|
|
12
|
+
spec.description = "X (formerly known as Twitter) OAuth2 strategy for OmniAuth." \
|
|
13
|
+
"'2' means OAuth 2.0, not successor of omniauth-twitter gem."
|
|
13
14
|
spec.homepage = "https://github.com/unasuke/omniauth-twitter2"
|
|
14
15
|
spec.license = "Apache-2.0"
|
|
15
16
|
spec.required_ruby_version = ">= 2.6.0"
|
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.
|
|
4
|
+
version: 1.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Yusuke Nakamura
|
|
8
8
|
bindir: exe
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: omniauth
|
|
@@ -37,7 +37,8 @@ dependencies:
|
|
|
37
37
|
- - "~>"
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
39
|
version: '1.0'
|
|
40
|
-
description: Twitter OAuth2 strategy for OmniAuth.
|
|
40
|
+
description: X (formerly known as Twitter) OAuth2 strategy for OmniAuth.'2' means
|
|
41
|
+
OAuth 2.0, not successor of omniauth-twitter gem.
|
|
41
42
|
email:
|
|
42
43
|
- yusuke1994525@gmail.com
|
|
43
44
|
executables: []
|
|
@@ -81,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
81
82
|
- !ruby/object:Gem::Version
|
|
82
83
|
version: '0'
|
|
83
84
|
requirements: []
|
|
84
|
-
rubygems_version:
|
|
85
|
+
rubygems_version: 4.0.10
|
|
85
86
|
specification_version: 4
|
|
86
|
-
summary: Twitter OAuth2 strategy for OmniAuth
|
|
87
|
+
summary: X (formerly known as Twitter) OAuth2 strategy for OmniAuth
|
|
87
88
|
test_files: []
|