omniauth-twitter 0.0.17 → 0.0.18
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.
- data/README.md +4 -0
- data/lib/omniauth-twitter/version.rb +1 -1
- data/lib/omniauth/strategies/twitter.rb +17 -1
- data/spec/omniauth/strategies/twitter_spec.rb +31 -3
- metadata +4 -4
data/README.md
CHANGED
@@ -46,6 +46,10 @@ 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
|
+
* **secure_image_url** - Set to `true` to use https for the user's image url. Default is `false`.
|
50
|
+
|
51
|
+
* **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`.
|
52
|
+
|
49
53
|
* **x_auth_access_type** - This option (described [here](https://dev.twitter.com/docs/api/1/post/oauth/request_token)) lets you request the level of access that your app will have to the Twitter account in question. *Example:* `http://yoursite.com/auth/twitter?x_auth_access_type=read`
|
50
54
|
|
51
55
|
* **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.
|
@@ -16,7 +16,7 @@ module OmniAuth
|
|
16
16
|
:nickname => raw_info['screen_name'],
|
17
17
|
:name => raw_info['name'],
|
18
18
|
:location => raw_info['location'],
|
19
|
-
:image => options
|
19
|
+
:image => image_url(options),
|
20
20
|
:description => raw_info['description'],
|
21
21
|
:urls => {
|
22
22
|
'Website' => raw_info['url'],
|
@@ -63,6 +63,22 @@ module OmniAuth
|
|
63
63
|
old_request_phase
|
64
64
|
end
|
65
65
|
|
66
|
+
private
|
67
|
+
|
68
|
+
def image_url(options)
|
69
|
+
original_url = options[:secure_image_url] ? raw_info['profile_image_url_https'] : raw_info['profile_image_url']
|
70
|
+
case options[:image_size]
|
71
|
+
when 'mini'
|
72
|
+
original_url.sub('normal', 'mini')
|
73
|
+
when 'bigger'
|
74
|
+
original_url.sub('normal', 'bigger')
|
75
|
+
when 'original'
|
76
|
+
original_url.sub('_normal', '')
|
77
|
+
else
|
78
|
+
original_url
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
66
82
|
end
|
67
83
|
end
|
68
84
|
end
|
@@ -2,10 +2,11 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe OmniAuth::Strategies::Twitter do
|
4
4
|
subject do
|
5
|
-
|
5
|
+
args = ['appid', 'secret', @options || {}].compact
|
6
|
+
OmniAuth::Strategies::Twitter.new(*args)
|
6
7
|
end
|
7
8
|
|
8
|
-
|
9
|
+
describe 'client options' do
|
9
10
|
it 'should have correct name' do
|
10
11
|
expect(subject.options.name).to eq('twitter')
|
11
12
|
end
|
@@ -19,8 +20,35 @@ describe OmniAuth::Strategies::Twitter do
|
|
19
20
|
end
|
20
21
|
end
|
21
22
|
|
23
|
+
describe 'image_size option' do
|
24
|
+
context 'when user has an image' do
|
25
|
+
it 'should return image with size specified' do
|
26
|
+
@options = { :image_size => 'original' }
|
27
|
+
subject.stub(:raw_info).and_return(
|
28
|
+
{ 'profile_image_url' => 'http://twimg0-a.akamaihd.net/sticky/default_profile_images/default_profile_0_normal.png' }
|
29
|
+
)
|
30
|
+
expect(subject.info[:image]).to eq('http://twimg0-a.akamaihd.net/sticky/default_profile_images/default_profile_0.png')
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should return secure image with size specified' do
|
34
|
+
@options = { :secure_image_url => 'true', :image_size => 'mini' }
|
35
|
+
subject.stub(:raw_info).and_return(
|
36
|
+
{ 'profile_image_url_https' => 'https://twimg0-a.akamaihd.net/sticky/default_profile_images/default_profile_0_normal.png' }
|
37
|
+
)
|
38
|
+
expect(subject.info[:image]).to eq('https://twimg0-a.akamaihd.net/sticky/default_profile_images/default_profile_0_mini.png')
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'should return normal image by default' do
|
42
|
+
subject.stub(:raw_info).and_return(
|
43
|
+
{ 'profile_image_url' => 'http://twimg0-a.akamaihd.net/sticky/default_profile_images/default_profile_0_normal.png' }
|
44
|
+
)
|
45
|
+
expect(subject.info[:image]).to eq('http://twimg0-a.akamaihd.net/sticky/default_profile_images/default_profile_0_normal.png')
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
22
50
|
describe 'request_phase' do
|
23
|
-
context 'no request params set and x_auth_access_type specified' do
|
51
|
+
context 'with no request params set and x_auth_access_type specified' do
|
24
52
|
before do
|
25
53
|
subject.options[:request_params] = nil
|
26
54
|
subject.stub(:session).and_return(
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniauth-twitter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.18
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-06-
|
12
|
+
date: 2013-06-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: multi_json
|
@@ -141,7 +141,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
141
141
|
version: '0'
|
142
142
|
segments:
|
143
143
|
- 0
|
144
|
-
hash:
|
144
|
+
hash: 131176557456009155
|
145
145
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
146
146
|
none: false
|
147
147
|
requirements:
|
@@ -150,7 +150,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
150
150
|
version: '0'
|
151
151
|
segments:
|
152
152
|
- 0
|
153
|
-
hash:
|
153
|
+
hash: 131176557456009155
|
154
154
|
requirements: []
|
155
155
|
rubyforge_project: omniauth-twitter
|
156
156
|
rubygems_version: 1.8.25
|