omniauth-meli 0.1.0 → 0.1.1
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/lib/omniauth/meli/version.rb +1 -1
- data/lib/omniauth/strategies/meli.rb +50 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 94c407589231d647dc2b8a2c9ca3eb5c129044598ea20f406ef2a7f63a4f9613
|
4
|
+
data.tar.gz: 597a3c42c0bf8635bc6afdd6f30bb695d349f89996023d58639abee084b25951
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 98bb293eea222ce7aa6d3e1ee2d6ec7f9c3cc5eaf91d613078704704473518617ef513f1bc28207a2793fb3bf17c40a8197317219bd6c7d39df95bb95e8a68de
|
7
|
+
data.tar.gz: 41e08fc74a8ba0fd9e99efad241ea83594352f67751594482dce76614046fa9a5640f528d13e11597454c381c8e03048e36b598ae31f8088d19ed70f45e49a87
|
data/.github/workflows/ruby.yml
CHANGED
data/.gitignore
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
|
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.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-
|
11
|
+
date: 2024-02-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: omniauth
|