twitter_oauth2 0.5.0 → 0.5.1
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/README.md +20 -1
- data/VERSION +1 -1
- data/lib/twitter_oauth2/client.rb +3 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b2e1d31e068391f9c383c7763c0e9d8d24bb9b8d5a103f40d322a8c86c8a7085
|
4
|
+
data.tar.gz: 935ea49eda4bb324c81e2a79f492311a98edbc9e5684ba6c03ba676372506a2d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3745818e6df3d018fad281cadf2f5d1259302b72b842fdff04651002f10f8b86134bb679ffbc1e0bcd682e58dbf923b1943df67473fbb92b54f4fd48ee6ff3d
|
7
|
+
data.tar.gz: a04f256212a7c240f2a17ba5a118b77e9fdfbecdd6f8ed85cd2417f8efec564740f9263a1f4248e1972a88583045f97041aaab05bb028ed8ea3f1abc67cd1694
|
data/README.md
CHANGED
@@ -29,7 +29,8 @@ The only difference is that this gem is supporting PKCE as default, since [Twitt
|
|
29
29
|
require 'twitter_oauth2'
|
30
30
|
|
31
31
|
client = TwitterOAuth2::Client.new(
|
32
|
-
identifier:
|
32
|
+
identifier: '<YOUR-CLIENT-ID>',
|
33
|
+
secret: '<YOUR-CLIENT-SECRET>',
|
33
34
|
redirect_uri: '<YOUR-CALLBACK-URL>'
|
34
35
|
)
|
35
36
|
|
@@ -38,6 +39,7 @@ authorization_uri = client.authorization_uri(
|
|
38
39
|
:'users.read',
|
39
40
|
:'tweet.read',
|
40
41
|
:'offline.access'
|
42
|
+
]
|
41
43
|
)
|
42
44
|
|
43
45
|
# NOTE:
|
@@ -63,6 +65,23 @@ client.refresh_token = token_response.refresh_token
|
|
63
65
|
client.access_token!
|
64
66
|
```
|
65
67
|
|
68
|
+
If you want to get App-only Bearer Token (via `grant_type=client_credentials`), you need some tweaks as below.
|
69
|
+
|
70
|
+
```ruby
|
71
|
+
require 'twitter_oauth2'
|
72
|
+
|
73
|
+
client = TwitterOAuth2::Client.new(
|
74
|
+
# NOTE: not OAuth 2.0 Client ID, but OAuth 1.0 Consumer Key (a.k.a API Key)
|
75
|
+
identifier: '<YOUR-CONSUMER-KEY>',
|
76
|
+
# NOTE: not OAuth 2.0 Client Secret, but OAuth 1.0 Consumer Secret (a.k.a API Key Secret)
|
77
|
+
secret: '<YOUR-CONSUMER-SECRET>'
|
78
|
+
# NOTE: Twitter has Client Credentials Grant specific token endpoint.
|
79
|
+
token_endpoint: '/oauth2/token',
|
80
|
+
)
|
81
|
+
|
82
|
+
client.access_token!
|
83
|
+
```
|
84
|
+
|
66
85
|
For more usage, read [the underling gem's wiki](https://github.com/nov/rack-oauth2/wiki).
|
67
86
|
|
68
87
|
## Development
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.1
|
@@ -4,15 +4,16 @@ module TwitterOAuth2
|
|
4
4
|
|
5
5
|
def initialize(attributes)
|
6
6
|
attributes_with_default = {
|
7
|
+
host: 'api.twitter.com',
|
7
8
|
authorization_endpoint: 'https://twitter.com/i/oauth2/authorize',
|
8
|
-
token_endpoint: '
|
9
|
+
token_endpoint: '/2/oauth2/token'
|
9
10
|
}.merge(attributes)
|
10
11
|
super attributes_with_default
|
11
12
|
end
|
12
13
|
|
13
14
|
def authorization_uri(params = {})
|
14
15
|
authorization_session!
|
15
|
-
|
16
|
+
super({
|
16
17
|
code_challenge: code_challenge,
|
17
18
|
code_challenge_method: code_challenge_method,
|
18
19
|
state: state
|