omniauth-meli 0.1.0 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3759e795e60e35d48b7348b35ec85621d04cb09f6597d7dfdbd1aecca78b50fa
4
- data.tar.gz: cb5c11111bfad7da7284a113b61fe724a86edbacaff22f5a1bf6f4b241e34218
3
+ metadata.gz: 94c407589231d647dc2b8a2c9ca3eb5c129044598ea20f406ef2a7f63a4f9613
4
+ data.tar.gz: 597a3c42c0bf8635bc6afdd6f30bb695d349f89996023d58639abee084b25951
5
5
  SHA512:
6
- metadata.gz: aecf36efc169695fb1c3394d2bdf66cc5212e4817b2e1e37ccbc14eb3e96156ccd257d64ce5733bd959426850e817da609a6ffba9414ce635d7475aee33bb1fc
7
- data.tar.gz: 33df571e38ebd7b5e710f368cd66bb513294f336ff4f004ff0f5c4511885a6f771c34d6a5ea0c34fd55a1ae4a3f0d100bb46667ceb4ae537015421b638df40d0
6
+ metadata.gz: 98bb293eea222ce7aa6d3e1ee2d6ec7f9c3cc5eaf91d613078704704473518617ef513f1bc28207a2793fb3bf17c40a8197317219bd6c7d39df95bb95e8a68de
7
+ data.tar.gz: 41e08fc74a8ba0fd9e99efad241ea83594352f67751594482dce76614046fa9a5640f528d13e11597454c381c8e03048e36b598ae31f8088d19ed70f45e49a87
@@ -13,7 +13,7 @@ jobs:
13
13
  runs-on: ubuntu-latest
14
14
  strategy:
15
15
  matrix:
16
- ruby-version: [2.6, 2.7, 3.0, 3.1, 3.2]
16
+ ruby-version: [3.2]
17
17
 
18
18
  steps:
19
19
  - uses: actions/checkout@v3
data/.gitignore CHANGED
@@ -6,7 +6,7 @@ doc
6
6
  pkg
7
7
  spec/reports
8
8
  tmp
9
- .gem
9
+ *.gem
10
10
  .rbc
11
11
  Gemfile.lock
12
12
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module OmniAuth
4
4
  module Meli
5
- VERSION = '0.1.0'
5
+ VERSION = '0.1.1'
6
6
  end
7
7
  end
@@ -6,23 +6,67 @@ module OmniAuth
6
6
  module Strategies
7
7
  # Omniauth strategy for authenticating with GitHub via OAuth2
8
8
  class Meli < OmniAuth::Strategies::OAuth2
9
+ option :name, 'mercadolivre'
10
+
9
11
  option :client_options, {
10
12
  site: 'https://api.mercadolibre.com',
11
- authorize_url: 'https://auth.mercadolibre.com.ar/authorization',
13
+ authorize_url: 'https://auth.mercadolivre.com.br/authorization',
12
14
  token_url: 'https://api.mercadolibre.com/oauth/token'
13
15
  }
14
16
 
15
17
  uid { raw_info['id'].to_s }
16
18
 
17
19
  info do
18
- {
19
- nickname: raw_info['nickname'],
20
- email: raw_info['email']
21
- }
20
+ deep_compact!(
21
+ {
22
+ nickname: raw_info['nickname'],
23
+ email: raw_info['email'],
24
+ first_name: raw_info['first_name'],
25
+ last_name: raw_info['last_name'],
26
+ image: raw_info['logo'],
27
+ url: raw_info['permalink']
28
+ }
29
+ )
30
+ end
31
+
32
+ extra do
33
+ hash = {}
34
+ hash[:access_token] = access_token.to_hash
35
+ hash[:raw_info] = raw_info unless skip_info?
36
+ deep_compact! hash
37
+ end
38
+
39
+ def authorize_params
40
+ super.tap do |params|
41
+ params[:response_type] = 'code'
42
+ params[:client_id] = client.id
43
+ params[:redirect_uri] = callback_url.to_s.downcase
44
+ end
45
+ end
46
+
47
+ def build_access_token
48
+ client.get_token(
49
+ {
50
+ code: request.params['code'],
51
+ redirect_uri: callback_url.to_s.downcase,
52
+ client_id: client.id,
53
+ client_secret: client.secret,
54
+ grant_type: 'authorization_code'
55
+ }
56
+ )
22
57
  end
23
58
 
24
59
  def raw_info
25
- @raw_info ||= access_token.get('/users/me').parsed || {}
60
+ @raw_info ||= access_token.get('users/me', { params: access_token.hash }).parsed || {}
61
+ end
62
+
63
+ private
64
+
65
+ def deep_compact!(hash)
66
+ hash.delete_if do |_, value|
67
+ deep_compact!(value) if value.is_a?(Hash)
68
+ value.nil? || (value.respond_to?(:empty?) && value.empty?)
69
+ end
26
70
  end
27
71
  end
28
72
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-meli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elton Fonseca
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-02-21 00:00:00.000000000 Z
11
+ date: 2024-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: omniauth