omniauth-square 0.9 → 1.0
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 +6 -3
- data/lib/omniauth-square/version.rb +1 -1
- data/lib/omniauth/strategies/square.rb +5 -2
- data/spec/omniauth/strategies/square_spec.rb +15 -4
- data/spec/support/shared_examples.rb +23 -0
- metadata +18 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3015d7085ea4b62fe7acaef16418425309a78865
|
4
|
+
data.tar.gz: 32af0a620290db597ebaff90e77418973db34e63
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9fad2731c3b71badf29ecb68c4a8575c4a77d1a007f18ad7f6c34bf36618fceb2779c899dded3fdd9f2cd99a1a0c7240d0eee07380880d606571b16bedd5c29c
|
7
|
+
data.tar.gz: 4123f50f54c0d9f80cbb239a58628a338d6000ce6a7a5a92e90d0e5656723150b6da9bb2a15627537f3bd1f1e1f01091fd62b029be09707eb9e839ea2b105558
|
data/README.md
CHANGED
@@ -8,16 +8,19 @@ Square uses the OAuth2 flow, you can read about it here: http://connect.squareup
|
|
8
8
|
|
9
9
|
So let's say you're using Rails, you need to add the strategy to your `Gemfile`:
|
10
10
|
|
11
|
-
gem 'omniauth-square'
|
11
|
+
gem 'omniauth-square', '~> 1.0'
|
12
12
|
|
13
|
-
You can pull
|
13
|
+
You can pull it in directly from github (if you really want to) e.g.:
|
14
14
|
|
15
15
|
gem 'omniauth-square', :git => 'https://github.com/danieljacobarcher/omniauth-square.git'
|
16
16
|
|
17
17
|
Once these are in, you need to add the following to your `config/initializers/omniauth.rb`:
|
18
18
|
|
19
19
|
Rails.application.config.middleware.use OmniAuth::Builder do
|
20
|
-
provider :square, "consumer_key", "consumer_secret"
|
20
|
+
provider :square, "consumer_key", "consumer_secret",
|
21
|
+
{
|
22
|
+
:connect_site => 'https://connect.squareup.com'
|
23
|
+
}
|
21
24
|
end
|
22
25
|
|
23
26
|
You will obviously have to put in your key and secret, which you get when you register your app with Square (they call them Application Key and Secret Key).
|
@@ -6,6 +6,7 @@ module OmniAuth
|
|
6
6
|
|
7
7
|
option :client_options, {
|
8
8
|
:site => 'https://squareup.com/',
|
9
|
+
:connect_site => 'https://connect.squareup.com',
|
9
10
|
:authorize_url => '/oauth2/authorize',
|
10
11
|
:token_url => '/oauth2/token'
|
11
12
|
}
|
@@ -26,7 +27,7 @@ module OmniAuth
|
|
26
27
|
end
|
27
28
|
|
28
29
|
def raw_info
|
29
|
-
@raw_info ||= access_token.get('
|
30
|
+
@raw_info ||= access_token.get('/v1/me').parsed
|
30
31
|
end
|
31
32
|
|
32
33
|
protected
|
@@ -37,7 +38,9 @@ module OmniAuth
|
|
37
38
|
parsed_response['expires_at'] = Time.parse(parsed_response['expires_at']).to_i
|
38
39
|
parsed_response.merge!(deep_symbolize(options.auth_token_params))
|
39
40
|
|
40
|
-
|
41
|
+
connect_client = client.dup
|
42
|
+
connect_client.site = options.client_options.connect_site
|
43
|
+
::OAuth2::AccessToken.from_hash(connect_client, parsed_response)
|
41
44
|
end
|
42
45
|
|
43
46
|
private
|
@@ -131,11 +131,22 @@ describe OmniAuth::Strategies::Square do
|
|
131
131
|
end
|
132
132
|
|
133
133
|
describe '#build_access_token' do
|
134
|
+
let(:token_hash) do
|
135
|
+
{'expires_at' => Time.now.iso8601, 'access_token' => '1111111'}
|
136
|
+
end
|
137
|
+
|
138
|
+
before do
|
139
|
+
subject.stub(:fetch_access_token).and_return(token_hash.dup)
|
140
|
+
@token = subject.send :build_access_token
|
141
|
+
end
|
142
|
+
|
134
143
|
it 'converts iso8601 expires_at to an integer' do
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
144
|
+
expires = Time.parse(token_hash['expires_at']).to_i
|
145
|
+
expect(@token.expires_at).to eq(expires)
|
146
|
+
end
|
147
|
+
|
148
|
+
it 'changes the clients site' do
|
149
|
+
expect(@token.client.site).to eq('https://connect.squareup.com')
|
139
150
|
end
|
140
151
|
end
|
141
152
|
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# NOTE it would be useful if this lived in omniauth-oauth2 eventually
|
2
|
+
shared_examples 'an oauth2 strategy' do
|
3
|
+
describe '#client' do
|
4
|
+
it 'should be initialized with symbolized client_options' do
|
5
|
+
@options = { :client_options => { 'authorize_url' => 'https://example.com' } }
|
6
|
+
subject.client.options[:authorize_url].should == 'https://example.com'
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
describe '#token_params' do
|
11
|
+
it 'should include any authorize params passed in the :authorize_params option' do
|
12
|
+
@options = { :token_params => { :foo => 'bar', :baz => 'zip' } }
|
13
|
+
subject.token_params['foo'].should eq('bar')
|
14
|
+
subject.token_params['baz'].should eq('zip')
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should include top-level options that are marked as :authorize_options' do
|
18
|
+
@options = { :token_options => [:scope, :foo], :scope => 'bar', :foo => 'baz' }
|
19
|
+
subject.token_params['scope'].should eq('bar')
|
20
|
+
subject.token_params['foo'].should eq('baz')
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniauth-square
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0
|
4
|
+
version: '1.0'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Archer
|
@@ -11,76 +11,76 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2014-07-
|
14
|
+
date: 2014-07-24 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: omniauth-oauth2
|
18
18
|
requirement: !ruby/object:Gem::Requirement
|
19
19
|
requirements:
|
20
|
-
- - ~>
|
20
|
+
- - "~>"
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: 1.1.1
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
|
-
- - ~>
|
27
|
+
- - "~>"
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: 1.1.1
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: rspec
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
33
33
|
requirements:
|
34
|
-
- - ~>
|
34
|
+
- - "~>"
|
35
35
|
- !ruby/object:Gem::Version
|
36
36
|
version: '2.7'
|
37
37
|
type: :development
|
38
38
|
prerelease: false
|
39
39
|
version_requirements: !ruby/object:Gem::Requirement
|
40
40
|
requirements:
|
41
|
-
- - ~>
|
41
|
+
- - "~>"
|
42
42
|
- !ruby/object:Gem::Version
|
43
43
|
version: '2.7'
|
44
44
|
- !ruby/object:Gem::Dependency
|
45
45
|
name: rack-test
|
46
46
|
requirement: !ruby/object:Gem::Requirement
|
47
47
|
requirements:
|
48
|
-
- -
|
48
|
+
- - ">="
|
49
49
|
- !ruby/object:Gem::Version
|
50
50
|
version: '0'
|
51
51
|
type: :development
|
52
52
|
prerelease: false
|
53
53
|
version_requirements: !ruby/object:Gem::Requirement
|
54
54
|
requirements:
|
55
|
-
- -
|
55
|
+
- - ">="
|
56
56
|
- !ruby/object:Gem::Version
|
57
57
|
version: '0'
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: simplecov
|
60
60
|
requirement: !ruby/object:Gem::Requirement
|
61
61
|
requirements:
|
62
|
-
- -
|
62
|
+
- - ">="
|
63
63
|
- !ruby/object:Gem::Version
|
64
64
|
version: '0'
|
65
65
|
type: :development
|
66
66
|
prerelease: false
|
67
67
|
version_requirements: !ruby/object:Gem::Requirement
|
68
68
|
requirements:
|
69
|
-
- -
|
69
|
+
- - ">="
|
70
70
|
- !ruby/object:Gem::Version
|
71
71
|
version: '0'
|
72
72
|
- !ruby/object:Gem::Dependency
|
73
73
|
name: webmock
|
74
74
|
requirement: !ruby/object:Gem::Requirement
|
75
75
|
requirements:
|
76
|
-
- -
|
76
|
+
- - ">="
|
77
77
|
- !ruby/object:Gem::Version
|
78
78
|
version: '0'
|
79
79
|
type: :development
|
80
80
|
prerelease: false
|
81
81
|
version_requirements: !ruby/object:Gem::Requirement
|
82
82
|
requirements:
|
83
|
-
- -
|
83
|
+
- - ">="
|
84
84
|
- !ruby/object:Gem::Version
|
85
85
|
version: '0'
|
86
86
|
description: Square OAuth strategy for OmniAuth
|
@@ -93,7 +93,7 @@ executables: []
|
|
93
93
|
extensions: []
|
94
94
|
extra_rdoc_files: []
|
95
95
|
files:
|
96
|
-
- .gitignore
|
96
|
+
- ".gitignore"
|
97
97
|
- Gemfile
|
98
98
|
- README.md
|
99
99
|
- Rakefile
|
@@ -103,6 +103,7 @@ files:
|
|
103
103
|
- omniauth-square.gemspec
|
104
104
|
- spec/omniauth/strategies/square_spec.rb
|
105
105
|
- spec/spec_helper.rb
|
106
|
+
- spec/support/shared_examples.rb
|
106
107
|
homepage: https://github.com/danieljacobarcher/omniauth-square
|
107
108
|
licenses:
|
108
109
|
- MIT
|
@@ -113,20 +114,21 @@ require_paths:
|
|
113
114
|
- lib
|
114
115
|
required_ruby_version: !ruby/object:Gem::Requirement
|
115
116
|
requirements:
|
116
|
-
- -
|
117
|
+
- - ">="
|
117
118
|
- !ruby/object:Gem::Version
|
118
119
|
version: '0'
|
119
120
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
120
121
|
requirements:
|
121
|
-
- -
|
122
|
+
- - ">="
|
122
123
|
- !ruby/object:Gem::Version
|
123
124
|
version: '0'
|
124
125
|
requirements: []
|
125
126
|
rubyforge_project: omniauth-square
|
126
|
-
rubygems_version: 2.
|
127
|
+
rubygems_version: 2.2.2
|
127
128
|
signing_key:
|
128
129
|
specification_version: 4
|
129
130
|
summary: Square OAuth strategy for OmniAuth
|
130
131
|
test_files:
|
131
132
|
- spec/omniauth/strategies/square_spec.rb
|
132
133
|
- spec/spec_helper.rb
|
134
|
+
- spec/support/shared_examples.rb
|