omniauth-square-oauth2 0.0.3 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b0e081d6663cb435b61e57f93417049a37914dc5936e07aaec7d9f95333361d2
4
- data.tar.gz: 9e76d9ed588620f437499b29c2918c26a048a62e206db0db8cc5359b7d584b11
3
+ metadata.gz: f19ab92a8efc93e052e61f76c30ae3aa747e5154e0c22ed05c1dd235a76d2999
4
+ data.tar.gz: 734bc25d8e398cc8d33b297b837dbafb7c1cffaa91254523cfed7525f89a2c45
5
5
  SHA512:
6
- metadata.gz: 7274361873c49e29f358e9e48ef65fb6b5d2e6cd496e05ec539514da68721acf1b9a0497df63b4181d2dd91dc252f8c187f44e6a0cee977e9884f35cac63f1ae
7
- data.tar.gz: a90cc7a83c2c6a2d82502aa78a7caa3937e7c84ff7729e786e9e8f3787e1ae7a01ed3d5dcdde5c076054d2d51e39a8ef92bbb5dc8f7a5a2a99a78cdee3392b8c
6
+ metadata.gz: e5f1b4c48dd0764ff141ead54e59435c026131cd407d6f430e673cad26aa8edf3d2f314d95a8bf10cfa6e9bc4ea898a6de68775981292d414933dc6e818c93e8
7
+ data.tar.gz: 913af461084fd09051c011e10d62202eff7d74f6862e6d6e9a16525bb27c4a3568a109d9eef3714dd760e6c56cc94565e08f8c64ee4317b6e763093cf75c45e1
data/Gemfile.lock CHANGED
@@ -2,7 +2,7 @@ PATH
2
2
  remote: .
3
3
  specs:
4
4
  omniauth-square-oauth2 (0.0.2)
5
- omniauth-oauth2 (>= 1.1.1, < 1.3.0)
5
+ omniauth-oauth2 (>= 1.7.3)
6
6
 
7
7
  GEM
8
8
  remote: http://rubygems.org/
@@ -13,37 +13,41 @@ GEM
13
13
  crack (0.4.4)
14
14
  diff-lcs (1.4.4)
15
15
  docile (1.3.2)
16
- faraday (0.9.2)
17
- multipart-post (>= 1.2, < 3)
16
+ faraday (2.5.2)
17
+ faraday-net_http (>= 2.0, < 3.1)
18
+ ruby2_keywords (>= 0.0.4)
19
+ faraday-net_http (3.0.0)
18
20
  hashdiff (1.0.1)
19
- hashie (4.1.0)
20
- jwt (2.2.2)
21
- multi_json (1.15.0)
21
+ hashie (5.0.0)
22
+ jwt (2.5.0)
22
23
  multi_xml (0.6.0)
23
- multipart-post (2.1.1)
24
- oauth2 (1.4.4)
25
- faraday (>= 0.8, < 2.0)
24
+ oauth2 (2.0.7)
25
+ faraday (>= 0.17.3, < 3.0)
26
26
  jwt (>= 1.0, < 3.0)
27
- multi_json (~> 1.3)
28
27
  multi_xml (~> 0.5)
29
28
  rack (>= 1.2, < 3)
30
- omniauth (1.9.1)
29
+ rash_alt (>= 0.4, < 1)
30
+ version_gem (~> 1.1)
31
+ omniauth (2.1.0)
31
32
  hashie (>= 3.4.6)
32
- rack (>= 1.6.2, < 3)
33
- omniauth-oauth2 (1.2.0)
34
- faraday (>= 0.8, < 0.10)
35
- multi_json (~> 1.3)
36
- oauth2 (~> 1.0)
37
- omniauth (~> 1.2)
33
+ rack (>= 2.2.3)
34
+ rack-protection
35
+ omniauth-oauth2 (1.8.0)
36
+ oauth2 (>= 1.4, < 3)
37
+ omniauth (~> 2.0)
38
38
  parallel (1.19.2)
39
39
  parser (2.7.2.0)
40
40
  ast (~> 2.4.1)
41
41
  public_suffix (4.0.6)
42
42
  rack (2.2.3)
43
+ rack-protection (2.2.2)
44
+ rack
43
45
  rack-test (1.1.0)
44
46
  rack (>= 1.0, < 3)
45
47
  rainbow (3.0.0)
46
48
  rake (10.5.0)
49
+ rash_alt (0.4.12)
50
+ hashie (>= 3.4)
47
51
  regexp_parser (1.8.1)
48
52
  rexml (3.2.4)
49
53
  rspec (2.99.0)
@@ -66,11 +70,13 @@ GEM
66
70
  rubocop-ast (0.7.1)
67
71
  parser (>= 2.7.1.5)
68
72
  ruby-progressbar (1.10.1)
73
+ ruby2_keywords (0.0.5)
69
74
  simplecov (0.19.0)
70
75
  docile (~> 1.1)
71
76
  simplecov-html (~> 0.11)
72
77
  simplecov-html (0.12.3)
73
78
  unicode-display_width (1.7.0)
79
+ version_gem (1.1.0)
74
80
  webmock (3.9.1)
75
81
  addressable (>= 2.3.6)
76
82
  crack (>= 0.3.2)
@@ -7,10 +7,9 @@ module OmniAuth
7
7
  class Square < OmniAuth::Strategies::OAuth2
8
8
  option :name, 'square'
9
9
  option :client_options, {
10
- site: 'https://squareup.com/',
11
- connect_site: 'https://connect.squareup.com',
12
- authorize_url: '/oauth2/authorize',
13
- token_url: '/oauth2/token'
10
+ site: 'https://connect.squareup.com',
11
+ authorize_url: 'oauth2/authorize',
12
+ token_url: 'oauth2/token'
14
13
  }
15
14
 
16
15
  uid { raw_info['merchant'][0]['id'] }
@@ -18,7 +17,8 @@ module OmniAuth
18
17
  info do
19
18
  prune!(
20
19
  name: raw_info['merchant'][0]['business_name'],
21
- country: raw_info['merchant'][0]['country']
20
+ country: raw_info['merchant'][0]['country'],
21
+ email: raw_info['email']
22
22
  )
23
23
  end
24
24
 
@@ -26,28 +26,23 @@ module OmniAuth
26
26
  { raw_info: raw_info }
27
27
  end
28
28
 
29
+ def callback_url
30
+ full_host + script_name + callback_path
31
+ end
32
+
29
33
  def build_access_token
30
- connect_client = client.dup
31
- connect_client.site = options.client_options.connect_site
32
- auth_params = {
33
- redirect_uri: callback_url,
34
- client_id: options.client_id,
35
- client_secret: options.client_secret,
36
- grant_type: 'authorization_code'
37
- }.merge(token_params.to_hash(symbolize_keys: true))
38
- connect_client.auth_code.get_token(
39
- request.params['code'],
40
- auth_params.merge(
41
- token_params.to_hash(symbolize_keys: true)
42
- ),
43
- deep_symbolize(options.auth_token_params)
44
- )
34
+ options.token_params.merge!({client_id: options.client_id, client_secret: options.client_secret})
35
+ super
45
36
  end
46
37
 
47
- private
38
+ private
48
39
 
49
40
  def raw_info
50
41
  @raw_info ||= access_token.get('/v2/merchants').parsed
42
+
43
+ # Get merchant email
44
+ team_members = access_token.post("/v2/team-members/search", {query: {filter: {is_owner: true}}})
45
+ @raw_info.merge!({email: team_members[0].email})
51
46
  end
52
47
 
53
48
  def prune!(hash)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Omniauth
4
4
  module Square
5
- VERSION = '0.0.3'
5
+ VERSION = '0.2.0'
6
6
  end
7
7
  end
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
18
18
  s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
19
19
  s.require_paths = ['lib']
20
20
 
21
- s.add_runtime_dependency 'omniauth-oauth2', '>= 1.1.1', '< 1.3.0'
21
+ s.add_runtime_dependency 'omniauth-oauth2', '>= 1.7.3'
22
22
  s.add_development_dependency 'rack-test'
23
23
  s.add_development_dependency 'rake', '~> 10.0'
24
24
  s.add_development_dependency 'rspec', '~> 2.7'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-square-oauth2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Robinson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-11 00:00:00.000000000 Z
11
+ date: 2023-05-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: omniauth-oauth2
@@ -16,20 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 1.1.1
20
- - - "<"
21
- - !ruby/object:Gem::Version
22
- version: 1.3.0
19
+ version: 1.7.3
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
24
  - - ">="
28
25
  - !ruby/object:Gem::Version
29
- version: 1.1.1
30
- - - "<"
31
- - !ruby/object:Gem::Version
32
- version: 1.3.0
26
+ version: 1.7.3
33
27
  - !ruby/object:Gem::Dependency
34
28
  name: rack-test
35
29
  requirement: !ruby/object:Gem::Requirement