omniauth-twitter 1.0.0 → 1.0.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 +7 -0
- data/README.md +90 -0
- data/lib/omniauth-twitter/version.rb +1 -1
- data/lib/omniauth/strategies/twitter.rb +15 -18
- data/spec/omniauth/strategies/twitter_spec.rb +10 -4
- metadata +13 -33
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9e6626f2d76da338cfcc7a60eb7881276193d59f
|
4
|
+
data.tar.gz: 5a4b555f23c9bff6d3947d485d18b8f85ce9392f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 35bced171375fac4f94231679e3707afbba5912a672cb284a30cc82f796736b2e67f32ee9fdbccfa8b41c2ad53f0e4f0e88a2ca9cd42aa787c13e0574da6a515
|
7
|
+
data.tar.gz: 813b9096c7ed44a87530a4a7bdb162040809f4a4711baf5cd2cbab3af0ff16d09d5cdd5fdf1593627dfb40ebee6d004e5df64f3572cf1ecd62c7aed910b88a30
|
data/README.md
CHANGED
@@ -46,6 +46,8 @@ The options are:
|
|
46
46
|
|
47
47
|
* **screen_name** - This option implies **force_login**, except the screen name field is pre-filled with a particular value. *Example:* `http://yoursite.com/auth/twitter?screen_name=jim`
|
48
48
|
|
49
|
+
* **lang** - The language used in the Twitter prompt. This is useful for adding i18n support since the language of the prompt can be dynamically set for each user. *Example:* `http://yoursite.com/auth/twitter?lang=pt`
|
50
|
+
|
49
51
|
* **secure_image_url** - Set to `true` to use https for the user's image url. Default is `false`.
|
50
52
|
|
51
53
|
* **image_size**: This option defines the size of the user's image. Valid options include `mini` (24x24), `normal` (48x48), `bigger` (73x73) and `original` (the size of the image originally uploaded). Default is `normal`.
|
@@ -54,6 +56,94 @@ The options are:
|
|
54
56
|
|
55
57
|
* **use_authorize** - There are actually two URLs you can use against the Twitter API. As mentioned, the default is `https://api.twitter.com/oauth/authenticate`, but you also have `https://api.twitter.com/oauth/authorize`. Passing this option as `true` will use the second URL rather than the first. What's the difference? As described [here](https://dev.twitter.com/docs/api/1/get/oauth/authenticate), with `authenticate`, if your user has already granted permission to your application, Twitter will redirect straight back to your application, whereas `authorize` forces the user to go through the "grant permission" screen again. For certain use cases this may be necessary. *Example:* `http://yoursite.com/auth/twitter?use_authorize=true`. *Note:* You must have "Allow this application to be used to Sign in with Twitter" checked in [your application's settings](https://dev.twitter.com/apps) - without it your user will be asked to authorize your application each time they log in.
|
56
58
|
|
59
|
+
Here's an example of a possible configuration where the the user's original profile picture is returned over https, the user is always prompted to sign-in and the default language of the Twitter prompt is changed:
|
60
|
+
|
61
|
+
```ruby
|
62
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
63
|
+
provider :twitter, ENV["TWITTER_KEY"], ENV["TWITTER_SECRET"],
|
64
|
+
{
|
65
|
+
:secure_image_url => 'true',
|
66
|
+
:image_size => 'original',
|
67
|
+
:authorize_params => {
|
68
|
+
:force_login => 'true',
|
69
|
+
:lang => 'pt'
|
70
|
+
}
|
71
|
+
}
|
72
|
+
end
|
73
|
+
```
|
74
|
+
|
75
|
+
## Authentication Hash
|
76
|
+
An example auth hash available in `request.env['omniauth.auth']`:
|
77
|
+
|
78
|
+
```ruby
|
79
|
+
{
|
80
|
+
:provider => "twitter",
|
81
|
+
:uid => "123456",
|
82
|
+
:info => {
|
83
|
+
:nickname => "johnqpublic",
|
84
|
+
:name => "John Q Public",
|
85
|
+
:location => "Anytown, USA",
|
86
|
+
:image => "http://si0.twimg.com/sticky/default_profile_images/default_profile_2_normal.png",
|
87
|
+
:description => "a very normal guy.",
|
88
|
+
:urls => {
|
89
|
+
:Website => nil,
|
90
|
+
:Twitter => "https://twitter.com/johnqpublic"
|
91
|
+
}
|
92
|
+
},
|
93
|
+
:credentials => {
|
94
|
+
:token => "a1b2c3d4...", # The OAuth 2.0 access token
|
95
|
+
:secret => "abcdef1234"
|
96
|
+
},
|
97
|
+
:extra => {
|
98
|
+
:access_token => "", # An OAuth::AccessToken object
|
99
|
+
:raw_info => {
|
100
|
+
:name => "John Q Public",
|
101
|
+
:listed_count" => 0,
|
102
|
+
:profile_sidebar_border_color" => "181A1E",
|
103
|
+
:url => nil,
|
104
|
+
:lang => "en",
|
105
|
+
:statuses_count => 129,
|
106
|
+
:profile_image_url => "http://si0.twimg.com/sticky/default_profile_images/default_profile_2_normal.png",
|
107
|
+
:profile_background_image_url_https => "https://twimg0-a.akamaihd.net/profile_background_images/229171796/pattern_036.gif",
|
108
|
+
:location => "Anytown, USA",
|
109
|
+
:time_zone => "Chicago",
|
110
|
+
:follow_request_sent => false,
|
111
|
+
:id => 123456,
|
112
|
+
:profile_background_tile => true,
|
113
|
+
:profile_sidebar_fill_color => "666666",
|
114
|
+
:followers_count => 1,
|
115
|
+
:default_profile_image => false,
|
116
|
+
:screen_name => "",
|
117
|
+
:following => false,
|
118
|
+
:utc_offset => -3600,
|
119
|
+
:verified => false,
|
120
|
+
:favourites_count => 0,
|
121
|
+
:profile_background_color => "1A1B1F",
|
122
|
+
:is_translator => false,
|
123
|
+
:friends_count => 1,
|
124
|
+
:notifications => false,
|
125
|
+
:geo_enabled => true,
|
126
|
+
:profile_background_image_url => "http://twimg0-a.akamaihd.net/profile_background_images/229171796/pattern_036.gif",
|
127
|
+
:protected => false,
|
128
|
+
:description => "a very normal guy.",
|
129
|
+
:profile_link_color => "2FC2EF",
|
130
|
+
:created_at => "Thu Jul 4 00:00:00 +0000 2013",
|
131
|
+
:id_str => "123456",
|
132
|
+
:profile_image_url_https => "https://si0.twimg.com/sticky/default_profile_images/default_profile_2_normal.png",
|
133
|
+
:default_profile => false,
|
134
|
+
:profile_use_background_image => false,
|
135
|
+
:entities => {
|
136
|
+
:description => {
|
137
|
+
:urls => []
|
138
|
+
}
|
139
|
+
},
|
140
|
+
:profile_text_color => "666666",
|
141
|
+
:contributors_enabled => false
|
142
|
+
}
|
143
|
+
}
|
144
|
+
}
|
145
|
+
```
|
146
|
+
|
57
147
|
## Watch the RailsCast
|
58
148
|
|
59
149
|
Ryan Bates has put together an excellent RailsCast on OmniAuth:
|
@@ -5,6 +5,7 @@ module OmniAuth
|
|
5
5
|
module Strategies
|
6
6
|
class Twitter < OmniAuth::Strategies::OAuth
|
7
7
|
option :name, 'twitter'
|
8
|
+
|
8
9
|
option :client_options, {:authorize_path => '/oauth/authenticate',
|
9
10
|
:site => 'https://api.twitter.com',
|
10
11
|
:proxy => ENV['http_proxy'] ? URI(ENV['http_proxy']) : nil}
|
@@ -16,7 +17,7 @@ module OmniAuth
|
|
16
17
|
:nickname => raw_info['screen_name'],
|
17
18
|
:name => raw_info['name'],
|
18
19
|
:location => raw_info['location'],
|
19
|
-
:image => image_url
|
20
|
+
:image => image_url,
|
20
21
|
:description => raw_info['description'],
|
21
22
|
:urls => {
|
22
23
|
'Website' => raw_info['url'],
|
@@ -38,26 +39,22 @@ module OmniAuth
|
|
38
39
|
alias :old_request_phase :request_phase
|
39
40
|
|
40
41
|
def request_phase
|
41
|
-
force_login
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
options[:authorize_params] ||= {}
|
46
|
-
options[:authorize_params].merge!(:force_login => 'true')
|
47
|
-
end
|
48
|
-
if screen_name && !screen_name.empty?
|
49
|
-
options[:authorize_params] ||= {}
|
50
|
-
options[:authorize_params].merge!(:screen_name => screen_name)
|
42
|
+
%w[force_login lang screen_name].each do |v|
|
43
|
+
if request.params[v]
|
44
|
+
options[:authorize_params][v.to_sym] = request.params[v]
|
45
|
+
end
|
51
46
|
end
|
52
|
-
|
53
|
-
|
54
|
-
|
47
|
+
|
48
|
+
%w[x_auth_access_type].each do |v|
|
49
|
+
if request.params[v]
|
50
|
+
options[:request_params][v.to_sym] = request.params[v]
|
51
|
+
end
|
55
52
|
end
|
56
53
|
|
57
|
-
if
|
58
|
-
options
|
54
|
+
if request.params['use_authorize'] == 'true'
|
55
|
+
options[:client_options][:authorize_path] = '/oauth/authorize'
|
59
56
|
else
|
60
|
-
options
|
57
|
+
options[:client_options][:authorize_path] = '/oauth/authenticate'
|
61
58
|
end
|
62
59
|
|
63
60
|
old_request_phase
|
@@ -65,7 +62,7 @@ module OmniAuth
|
|
65
62
|
|
66
63
|
private
|
67
64
|
|
68
|
-
def image_url
|
65
|
+
def image_url
|
69
66
|
original_url = options[:secure_image_url] ? raw_info['profile_image_url_https'] : raw_info['profile_image_url']
|
70
67
|
case options[:image_size]
|
71
68
|
when 'mini'
|
@@ -1,9 +1,15 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe OmniAuth::Strategies::Twitter do
|
4
|
+
let(:request) { double('Request', :params => {}, :cookies => {}, :env => {}) }
|
5
|
+
|
4
6
|
subject do
|
5
7
|
args = ['appid', 'secret', @options || {}].compact
|
6
|
-
OmniAuth::Strategies::Twitter.new(*args)
|
8
|
+
OmniAuth::Strategies::Twitter.new(*args).tap do |strategy|
|
9
|
+
strategy.stub(:request) {
|
10
|
+
request
|
11
|
+
}
|
12
|
+
end
|
7
13
|
end
|
8
14
|
|
9
15
|
describe 'client options' do
|
@@ -50,9 +56,9 @@ describe OmniAuth::Strategies::Twitter do
|
|
50
56
|
describe 'request_phase' do
|
51
57
|
context 'with no request params set and x_auth_access_type specified' do
|
52
58
|
before do
|
53
|
-
subject.
|
54
|
-
|
55
|
-
|
59
|
+
subject.stub(:request).and_return(
|
60
|
+
double('Request', {:params => {'x_auth_access_type' => 'read'}})
|
61
|
+
)
|
56
62
|
subject.stub(:old_request_phase).and_return(:whatever)
|
57
63
|
end
|
58
64
|
|
metadata
CHANGED
@@ -1,20 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniauth-twitter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
5
|
-
prerelease:
|
4
|
+
version: 1.0.1
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Arun Agrawal
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-
|
11
|
+
date: 2013-10-04 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: multi_json
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
17
|
- - ~>
|
20
18
|
- !ruby/object:Gem::Version
|
@@ -22,7 +20,6 @@ dependencies:
|
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
24
|
- - ~>
|
28
25
|
- !ruby/object:Gem::Version
|
@@ -30,7 +27,6 @@ dependencies:
|
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: omniauth-oauth
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
31
|
- - ~>
|
36
32
|
- !ruby/object:Gem::Version
|
@@ -38,7 +34,6 @@ dependencies:
|
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
38
|
- - ~>
|
44
39
|
- !ruby/object:Gem::Version
|
@@ -46,7 +41,6 @@ dependencies:
|
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: rspec
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
45
|
- - ~>
|
52
46
|
- !ruby/object:Gem::Version
|
@@ -54,7 +48,6 @@ dependencies:
|
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
52
|
- - ~>
|
60
53
|
- !ruby/object:Gem::Version
|
@@ -62,49 +55,43 @@ dependencies:
|
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: rack-test
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
|
-
- -
|
59
|
+
- - '>='
|
68
60
|
- !ruby/object:Gem::Version
|
69
61
|
version: '0'
|
70
62
|
type: :development
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
|
-
- -
|
66
|
+
- - '>='
|
76
67
|
- !ruby/object:Gem::Version
|
77
68
|
version: '0'
|
78
69
|
- !ruby/object:Gem::Dependency
|
79
70
|
name: simplecov
|
80
71
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
72
|
requirements:
|
83
|
-
- -
|
73
|
+
- - '>='
|
84
74
|
- !ruby/object:Gem::Version
|
85
75
|
version: '0'
|
86
76
|
type: :development
|
87
77
|
prerelease: false
|
88
78
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
79
|
requirements:
|
91
|
-
- -
|
80
|
+
- - '>='
|
92
81
|
- !ruby/object:Gem::Version
|
93
82
|
version: '0'
|
94
83
|
- !ruby/object:Gem::Dependency
|
95
84
|
name: webmock
|
96
85
|
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
86
|
requirements:
|
99
|
-
- -
|
87
|
+
- - '>='
|
100
88
|
- !ruby/object:Gem::Version
|
101
89
|
version: '0'
|
102
90
|
type: :development
|
103
91
|
prerelease: false
|
104
92
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
93
|
requirements:
|
107
|
-
- -
|
94
|
+
- - '>='
|
108
95
|
- !ruby/object:Gem::Version
|
109
96
|
version: '0'
|
110
97
|
description: OmniAuth strategy for Twitter
|
@@ -129,33 +116,26 @@ files:
|
|
129
116
|
homepage: https://github.com/arunagw/omniauth-twitter
|
130
117
|
licenses:
|
131
118
|
- MIT
|
119
|
+
metadata: {}
|
132
120
|
post_install_message:
|
133
121
|
rdoc_options: []
|
134
122
|
require_paths:
|
135
123
|
- lib
|
136
124
|
required_ruby_version: !ruby/object:Gem::Requirement
|
137
|
-
none: false
|
138
125
|
requirements:
|
139
|
-
- -
|
126
|
+
- - '>='
|
140
127
|
- !ruby/object:Gem::Version
|
141
128
|
version: '0'
|
142
|
-
segments:
|
143
|
-
- 0
|
144
|
-
hash: 248112754697321347
|
145
129
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
146
|
-
none: false
|
147
130
|
requirements:
|
148
|
-
- -
|
131
|
+
- - '>='
|
149
132
|
- !ruby/object:Gem::Version
|
150
133
|
version: '0'
|
151
|
-
segments:
|
152
|
-
- 0
|
153
|
-
hash: 248112754697321347
|
154
134
|
requirements: []
|
155
135
|
rubyforge_project: omniauth-twitter
|
156
|
-
rubygems_version:
|
136
|
+
rubygems_version: 2.0.6
|
157
137
|
signing_key:
|
158
|
-
specification_version:
|
138
|
+
specification_version: 4
|
159
139
|
summary: OmniAuth strategy for Twitter
|
160
140
|
test_files:
|
161
141
|
- spec/omniauth/strategies/twitter_spec.rb
|