omniauth-meli 0.1.0 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3759e795e60e35d48b7348b35ec85621d04cb09f6597d7dfdbd1aecca78b50fa
4
- data.tar.gz: cb5c11111bfad7da7284a113b61fe724a86edbacaff22f5a1bf6f4b241e34218
3
+ metadata.gz: d195617c64f92905dc97b2f08e609d944208c5bac27ce4c63331273fa432b72b
4
+ data.tar.gz: '0992218f027eb10b303744b8cd980f171a0e255d69676953593d22a9c5b5a4ce'
5
5
  SHA512:
6
- metadata.gz: aecf36efc169695fb1c3394d2bdf66cc5212e4817b2e1e37ccbc14eb3e96156ccd257d64ce5733bd959426850e817da609a6ffba9414ce635d7475aee33bb1fc
7
- data.tar.gz: 33df571e38ebd7b5e710f368cd66bb513294f336ff4f004ff0f5c4511885a6f771c34d6a5ea0c34fd55a1ae4a3f0d100bb46667ceb4ae537015421b638df40d0
6
+ metadata.gz: d7e217aef859846eeaca9f43e4f437a3e0718acc52a20deb59ef7b2d1ef7fc166fc8766dd6845cb16d83932d4f608c65a104bc29c19e30b1afdfdae8b2e32b0f
7
+ data.tar.gz: e899048bff0fa5664564a78fe2d6fd488e1ccddeedfd8cf364887b2b546c6eed19c145af177dbee5d12fac19bad3ba08f5657139eb398ca73cd8490ca6ffbb16
@@ -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
 
data/.rubocop.yml CHANGED
@@ -1,5 +1,8 @@
1
1
  AllCops:
2
2
  TargetRubyVersion: 3.2.2
3
3
 
4
+ Style/FileName:
5
+ Enabled: false
6
+
4
7
  Layout/LineLength:
5
8
  Max: 200
@@ -2,6 +2,6 @@
2
2
 
3
3
  module OmniAuth
4
4
  module Meli
5
- VERSION = '0.1.0'
5
+ VERSION = '0.1.2'
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
data/spec/spec_helper.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rspec'
2
4
 
3
5
  require 'omniauth'
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.2
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
@@ -83,7 +83,7 @@ files:
83
83
  - LICENSE.txt
84
84
  - README.md
85
85
  - Rakefile
86
- - lib/omniauth/meli.rb
86
+ - lib/omniauth-meli.rb
87
87
  - lib/omniauth/meli/version.rb
88
88
  - lib/omniauth/strategies/meli.rb
89
89
  - omniauth-meli.gemspec
File without changes