twitter_oauth2 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -4
- data/VERSION +1 -1
- data/lib/twitter_oauth2/client.rb +11 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f122e87aaf15c361806ef0e5b433d4581e5917602ccb1ecdc3ffc143dccb8c9a
|
4
|
+
data.tar.gz: ab48249dd3d6ef1d43028bb9fd80896a3b6f9dd051dd3def027cc92d6f6da7a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e28f5eef3c5b78cc78ef8fe46afb019bed576d9ee45a7f6ae74a9618fda9d3e6e549bd189c702dcaafa85d4ee148745b034c2fb5cefac1bfe9c849683e7b035
|
7
|
+
data.tar.gz: bc2708b3af710699168313319fa51b47a63cd640a1998b65b5890143f450203e20f5e948040577420adf2f8d2871f718e219e16c1f7a697e8655bcf5097e3e97
|
data/README.md
CHANGED
@@ -38,15 +38,15 @@ authorization_uri = client.authorization_uri(
|
|
38
38
|
:'users.read',
|
39
39
|
:'tweet.read',
|
40
40
|
:'offline.access'
|
41
|
-
],
|
42
|
-
state: SecureRandom.hex(16)
|
43
41
|
)
|
44
42
|
|
45
43
|
# NOTE:
|
46
|
-
# When
|
47
|
-
# PKCE `code_verifier`
|
44
|
+
# When `TwitterOAuth2::Client#authorization_uri` is called,
|
45
|
+
# PKCE `code_verifier` and `state` are automatically generated.
|
48
46
|
# You can get it here.
|
47
|
+
|
49
48
|
code_verifier = client.code_verifier
|
49
|
+
state = client.state
|
50
50
|
|
51
51
|
puts authorization_uri
|
52
52
|
`open "#{authorization_uri}"`
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.4.0
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module TwitterOAuth2
|
2
2
|
class Client < Rack::OAuth2::Client
|
3
|
-
attr_accessor :code_verifier
|
3
|
+
attr_accessor :code_verifier, :code_challenge, :code_challenge_method, :state
|
4
4
|
|
5
5
|
def initialize(attributes)
|
6
6
|
attributes_with_default = {
|
@@ -11,10 +11,11 @@ module TwitterOAuth2
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def authorization_uri(params = {})
|
14
|
-
|
14
|
+
authorization_session!
|
15
15
|
authorization_uri = super({
|
16
16
|
code_challenge: code_challenge,
|
17
|
-
code_challenge_method:
|
17
|
+
code_challenge_method: code_challenge_method,
|
18
|
+
state: state
|
18
19
|
}.merge(params))
|
19
20
|
end
|
20
21
|
|
@@ -27,15 +28,20 @@ module TwitterOAuth2
|
|
27
28
|
|
28
29
|
private
|
29
30
|
|
30
|
-
def
|
31
|
+
def authorization_session!
|
32
|
+
self.state = Base64.urlsafe_encode64(
|
33
|
+
SecureRandom.random_bytes(16),
|
34
|
+
padding: false
|
35
|
+
)
|
31
36
|
self.code_verifier = Base64.urlsafe_encode64(
|
32
37
|
SecureRandom.random_bytes(32),
|
33
38
|
padding: false
|
34
39
|
)
|
35
|
-
Base64.urlsafe_encode64(
|
40
|
+
self.code_challenge = Base64.urlsafe_encode64(
|
36
41
|
OpenSSL::Digest::SHA256.digest(code_verifier),
|
37
42
|
padding: false
|
38
43
|
)
|
44
|
+
self.code_challenge_method = :s256
|
39
45
|
end
|
40
46
|
end
|
41
47
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: twitter_oauth2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- nov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-10-
|
11
|
+
date: 2021-10-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack-oauth2
|