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 +4 -4
- data/.github/workflows/ruby.yml +1 -1
- data/.gitignore +1 -1
- data/.rubocop.yml +3 -0
- data/lib/omniauth/meli/version.rb +1 -1
- data/lib/omniauth/strategies/meli.rb +50 -6
- data/spec/spec_helper.rb +2 -0
- metadata +3 -3
- /data/lib/{omniauth/meli.rb → omniauth-meli.rb} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d195617c64f92905dc97b2f08e609d944208c5bac27ce4c63331273fa432b72b
|
4
|
+
data.tar.gz: '0992218f027eb10b303744b8cd980f171a0e255d69676953593d22a9c5b5a4ce'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d7e217aef859846eeaca9f43e4f437a3e0718acc52a20deb59ef7b2d1ef7fc166fc8766dd6845cb16d83932d4f608c65a104bc29c19e30b1afdfdae8b2e32b0f
|
7
|
+
data.tar.gz: e899048bff0fa5664564a78fe2d6fd488e1ccddeedfd8cf364887b2b546c6eed19c145af177dbee5d12fac19bad3ba08f5657139eb398ca73cd8490ca6ffbb16
|
data/.github/workflows/ruby.yml
CHANGED
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -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.
|
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
|
-
|
20
|
-
|
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('
|
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
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.
|
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-
|
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
|
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
|