twitter_oauth2 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b4e38a68d54be58e74f4ffc2236f0df0c2aa9a9d872eb180af0f902dcb0f3a1e
4
- data.tar.gz: e0f00e6f8bf166574fdf636f6228c3a6adbcd0e7cfc79ac3ff280654411d8a05
3
+ metadata.gz: b2e1d31e068391f9c383c7763c0e9d8d24bb9b8d5a103f40d322a8c86c8a7085
4
+ data.tar.gz: 935ea49eda4bb324c81e2a79f492311a98edbc9e5684ba6c03ba676372506a2d
5
5
  SHA512:
6
- metadata.gz: a9b38da9a8e90292815b6a8fbe162886780c93225ff6006f9d4c9fb64213958340c1e833aa4678aa1883ce31f74478fb1a058bfc4619b09697e899d31765dd02
7
- data.tar.gz: 719fbeadae3a8813317e50a4ea5fa1c0e746f528440405f5534f0f690aea8a6bc0d3eab52b8b8c2938180f3c2d28d380d68afb8937c9d429e7bfa4810c2a37cb
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: '<YOUR-CLIENT-ID>',
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.0
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: 'https://api.twitter.com/2/oauth2/token'
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
- authorization_uri = super({
16
+ super({
16
17
  code_challenge: code_challenge,
17
18
  code_challenge_method: code_challenge_method,
18
19
  state: state
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twitter_oauth2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - nov