omniauth-foursquare 1.0.0 → 1.0.1
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 -1
- data/lib/omniauth-foursquare/version.rb +1 -1
- data/lib/omniauth/strategies/foursquare.rb +15 -13
- data/spec/omniauth/strategies/foursquare_spec.rb +24 -15
- metadata +20 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4e4bdb46a5b1a4e1c0f5d517a64a16dfabc5e8bf
|
4
|
+
data.tar.gz: 2bf0da1f827a3e8d4ce1c3a89f317f7df1d4530b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 85981ba234b5d03f4e475369bb09b98d07f4006ffb591a3d120134d30fd71e109327cbb47f9ca77b1b7fbb3d36052317b47f20cab11dc79707889c4eba2e3c50
|
7
|
+
data.tar.gz: 112d18cdca871b8a34c6409d0af88cc40bf662ad449733b22f0790c98d101bc76776f2ed7382f4bad535c8d6296c2f7996734267497e243e3a52c7b3b7d09145
|
data/README.md
CHANGED
@@ -39,4 +39,7 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
39
39
|
|
40
40
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
41
41
|
|
42
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
42
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
43
|
+
|
44
|
+
[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/arunagw/omniauth-foursquare/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
|
45
|
+
|
@@ -8,20 +8,22 @@ module OmniAuth
|
|
8
8
|
:authorize_url => '/oauth2/authenticate',
|
9
9
|
:token_url => '/oauth2/access_token'
|
10
10
|
}
|
11
|
-
|
11
|
+
|
12
12
|
uid { raw_info['id'] }
|
13
|
-
|
13
|
+
|
14
14
|
info do
|
15
15
|
{
|
16
|
-
:first_name
|
17
|
-
:last_name
|
18
|
-
:name
|
19
|
-
:email
|
20
|
-
:
|
21
|
-
:
|
16
|
+
:first_name => raw_info['firstName'],
|
17
|
+
:last_name => raw_info['lastName'],
|
18
|
+
:name => "#{raw_info['firstName']} #{raw_info['lastName']}",
|
19
|
+
:email => (raw_info['contact'] || {})['email'],
|
20
|
+
:phone => (raw_info['contact'] || {})['phone'],
|
21
|
+
:image => raw_info['photo'],
|
22
|
+
:location => raw_info['homeCity'],
|
23
|
+
:description => raw_info['bio']
|
22
24
|
}
|
23
25
|
end
|
24
|
-
|
26
|
+
|
25
27
|
extra do
|
26
28
|
{ :raw_info => raw_info }
|
27
29
|
end
|
@@ -30,20 +32,20 @@ module OmniAuth
|
|
30
32
|
options[:authorize_params] = client_params.merge(options[:authorize_params])
|
31
33
|
super
|
32
34
|
end
|
33
|
-
|
35
|
+
|
34
36
|
def auth_hash
|
35
37
|
OmniAuth::Utils.deep_merge(super, client_params.merge({
|
36
38
|
:grant_type => 'authorization_code'}))
|
37
39
|
end
|
38
|
-
|
40
|
+
|
39
41
|
def raw_info
|
40
42
|
access_token.options[:mode] = :query
|
41
43
|
access_token.options[:param_name] = :oauth_token
|
42
44
|
@raw_info ||= access_token.get('https://api.foursquare.com/v2/users/self?v=20140128').parsed['response']['user']
|
43
45
|
end
|
44
|
-
|
46
|
+
|
45
47
|
private
|
46
|
-
|
48
|
+
|
47
49
|
def client_params
|
48
50
|
{:client_id => options[:client_id], :redirect_uri => callback_url ,:response_type => "code"}
|
49
51
|
end
|
@@ -6,7 +6,7 @@ describe OmniAuth::Strategies::Foursquare do
|
|
6
6
|
@request = double('Request')
|
7
7
|
@request.stub(:params) { {} }
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
10
|
subject do
|
11
11
|
OmniAuth::Strategies::Foursquare.new(nil, @options || {}).tap do |strategy|
|
12
12
|
strategy.stub(:request) { @request }
|
@@ -32,27 +32,28 @@ describe OmniAuth::Strategies::Foursquare do
|
|
32
32
|
describe '#info' do
|
33
33
|
before :each do
|
34
34
|
@raw_info = {
|
35
|
-
'name' => 'Sir Fred Smith',
|
36
35
|
'firstName' => 'Fred',
|
37
36
|
'lastName' => 'Smith',
|
38
37
|
'contact' => {
|
39
|
-
'email' => 'fred@example.com'
|
38
|
+
'email' => 'fred@example.com',
|
39
|
+
'phone' => '+1 555 555-5555',
|
40
40
|
},
|
41
41
|
'photo' => 'https://img-s.foursquare.com/userpix_thumbs/blank_boy.jpg',
|
42
|
-
'homeCity' => 'Chicago'
|
42
|
+
'homeCity' => 'Chicago',
|
43
|
+
'bio' => 'I am a guy from Chicago.'
|
43
44
|
}
|
44
45
|
subject.stub(:raw_info) { @raw_info }
|
45
46
|
end
|
46
|
-
|
47
|
+
|
47
48
|
context 'when data is present in raw info' do
|
48
49
|
it 'returns the combined name' do
|
49
|
-
subject.info[:name].should eq('
|
50
|
+
subject.info[:name].should eq('Fred Smith')
|
50
51
|
end
|
51
52
|
|
52
53
|
it 'returns the first name' do
|
53
54
|
subject.info[:first_name].should eq('Fred')
|
54
55
|
end
|
55
|
-
|
56
|
+
|
56
57
|
it 'returns the last name' do
|
57
58
|
subject.info[:last_name].should eq('Smith')
|
58
59
|
end
|
@@ -61,6 +62,10 @@ describe OmniAuth::Strategies::Foursquare do
|
|
61
62
|
subject.info[:email].should eq('fred@example.com')
|
62
63
|
end
|
63
64
|
|
65
|
+
it 'returns the phone number' do
|
66
|
+
subject.info[:phone].should eq('+1 555 555-5555')
|
67
|
+
end
|
68
|
+
|
64
69
|
it "sets the email blank if contact block is missing in raw_info" do
|
65
70
|
@raw_info.delete('contact')
|
66
71
|
subject.info[:email].should be_nil
|
@@ -73,9 +78,13 @@ describe OmniAuth::Strategies::Foursquare do
|
|
73
78
|
it 'returns the user location' do
|
74
79
|
subject.info[:location].should eq('Chicago')
|
75
80
|
end
|
81
|
+
|
82
|
+
it 'returns the user description' do
|
83
|
+
subject.info[:description].should eq('I am a guy from Chicago.')
|
84
|
+
end
|
76
85
|
end
|
77
86
|
end
|
78
|
-
|
87
|
+
|
79
88
|
describe '#credentials' do
|
80
89
|
before :each do
|
81
90
|
@access_token = double('OAuth2::AccessToken')
|
@@ -85,24 +94,24 @@ describe OmniAuth::Strategies::Foursquare do
|
|
85
94
|
@access_token.stub(:refresh_token)
|
86
95
|
subject.stub(:access_token) { @access_token }
|
87
96
|
end
|
88
|
-
|
97
|
+
|
89
98
|
it 'returns a Hash' do
|
90
99
|
subject.credentials.should be_a(Hash)
|
91
100
|
end
|
92
|
-
|
101
|
+
|
93
102
|
it 'returns the token' do
|
94
103
|
@access_token.stub(:token) { '123' }
|
95
104
|
subject.credentials['token'].should eq('123')
|
96
105
|
end
|
97
|
-
|
106
|
+
|
98
107
|
it 'returns the expiry status' do
|
99
108
|
@access_token.stub(:expires?) { true }
|
100
109
|
subject.credentials['expires'].should eq(true)
|
101
|
-
|
110
|
+
|
102
111
|
@access_token.stub(:expires?) { false }
|
103
112
|
subject.credentials['expires'].should eq(false)
|
104
113
|
end
|
105
|
-
|
114
|
+
|
106
115
|
it 'returns the refresh token and expiry time when expiring' do
|
107
116
|
ten_mins_from_now = (Time.now + 360).to_i
|
108
117
|
@access_token.stub(:expires?) { true }
|
@@ -111,14 +120,14 @@ describe OmniAuth::Strategies::Foursquare do
|
|
111
120
|
subject.credentials['refresh_token'].should eq('321')
|
112
121
|
subject.credentials['expires_at'].should eq(ten_mins_from_now)
|
113
122
|
end
|
114
|
-
|
123
|
+
|
115
124
|
it 'does not return the refresh token when it is nil and expiring' do
|
116
125
|
@access_token.stub(:expires?) { true }
|
117
126
|
@access_token.stub(:refresh_token) { nil }
|
118
127
|
subject.credentials['refresh_token'].should be_nil
|
119
128
|
subject.credentials.should_not have_key('refresh_token')
|
120
129
|
end
|
121
|
-
|
130
|
+
|
122
131
|
it 'does not return the refresh token when not expiring' do
|
123
132
|
@access_token.stub(:expires?) { false }
|
124
133
|
@access_token.stub(:refresh_token) { 'XXX' }
|
metadata
CHANGED
@@ -1,97 +1,97 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniauth-foursquare
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arun Agrawal
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-03-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: omniauth
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: omniauth-oauth2
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '1.0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '2.7'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - ~>
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '2.7'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rack-test
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: simplecov
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: webmock
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
description: Foursquare OAuth strategy for OmniAuth
|
@@ -101,9 +101,9 @@ executables: []
|
|
101
101
|
extensions: []
|
102
102
|
extra_rdoc_files: []
|
103
103
|
files:
|
104
|
-
- .gitignore
|
105
|
-
- .rspec
|
106
|
-
- .travis.yml
|
104
|
+
- ".gitignore"
|
105
|
+
- ".rspec"
|
106
|
+
- ".travis.yml"
|
107
107
|
- Gemfile
|
108
108
|
- README.md
|
109
109
|
- Rakefile
|
@@ -123,17 +123,17 @@ require_paths:
|
|
123
123
|
- lib
|
124
124
|
required_ruby_version: !ruby/object:Gem::Requirement
|
125
125
|
requirements:
|
126
|
-
- -
|
126
|
+
- - ">="
|
127
127
|
- !ruby/object:Gem::Version
|
128
128
|
version: '0'
|
129
129
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
130
130
|
requirements:
|
131
|
-
- -
|
131
|
+
- - ">="
|
132
132
|
- !ruby/object:Gem::Version
|
133
133
|
version: '0'
|
134
134
|
requirements: []
|
135
135
|
rubyforge_project: omniauth-foursquare
|
136
|
-
rubygems_version: 2.
|
136
|
+
rubygems_version: 2.2.2
|
137
137
|
signing_key:
|
138
138
|
specification_version: 4
|
139
139
|
summary: Foursquare OAuth strategy for OmniAuth
|