omniauth-zalo 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -17
- data/lib/omniauth/strategies/build_access_token.rb +46 -0
- data/lib/omniauth/strategies/zalo.rb +14 -17
- data/lib/omniauth/zalo/version.rb +1 -1
- data/lib/omniauth/zalo.rb +1 -0
- metadata +7 -12
- data/lib/omniauth/zalo/oauth.rb +0 -25
- data/omniauth-zalo-0.1.0.gem +0 -0
- data/omniauth-zalo-0.1.1.gem +0 -0
- data/omniauth-zalo-0.1.2.gem +0 -0
- data/omniauth-zalo-0.1.3.gem +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 292344ac127119e787f65937437da02b1b78695e0619449e87bddca5af2be89d
|
4
|
+
data.tar.gz: b8e4311dd36265f0a86cfaa015f92002ae5e19503493672515e123e63db55dc2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a60be850cc6fccb9f2f6d00e53091f971a64e21abbd94af369e121422182f88919abb8b97099e7f8baf3c2c9ad4c796135fdac365db3395076956a477203518d
|
7
|
+
data.tar.gz: 964626fc00cfacb419a7baf1f0f9d1355181169ac51cfaa1dde481efb065e543c0f441f8a726d59ccc8d529f2f361fbb1c251c7cc9a3512f226126fe786aea7d
|
data/README.md
CHANGED
@@ -1,8 +1,6 @@
|
|
1
|
-
#
|
1
|
+
# OmniAuth::Zalo
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
3
|
+
OmniAuth strategy for [Sign In with Zalo](https://developers.zalo.me/).
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
@@ -14,7 +12,7 @@ gem 'omniauth-zalo'
|
|
14
12
|
|
15
13
|
And then execute:
|
16
14
|
|
17
|
-
$ bundle
|
15
|
+
$ bundle install
|
18
16
|
|
19
17
|
Or install it yourself as:
|
20
18
|
|
@@ -23,28 +21,18 @@ Or install it yourself as:
|
|
23
21
|
## Usage
|
24
22
|
omniauth.rb
|
25
23
|
|
26
|
-
```
|
24
|
+
```ruby
|
27
25
|
Rails.application.config.middleware.use OmniAuth::Builder do
|
28
26
|
provider :zalo, ENV['APP_ID'], env['SERECT_ID']
|
29
27
|
end
|
30
28
|
```
|
31
29
|
|
32
|
-
TODO: Write usage instructions here
|
33
|
-
|
34
|
-
## Development
|
35
|
-
|
36
|
-
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
37
|
-
|
38
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
39
30
|
|
40
31
|
## Contributing
|
41
32
|
|
42
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
33
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/nguyenthanhcong101096/omniauth-zalo
|
43
34
|
|
44
35
|
## License
|
45
36
|
|
46
37
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
47
38
|
|
48
|
-
## Code of Conduct
|
49
|
-
|
50
|
-
Everyone interacting in the Omniauth::Zalo project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/omniauth-zalo/blob/master/CODE_OF_CONDUCT.md).
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module OmniAuth
|
2
|
+
module Strategies
|
3
|
+
module BuildAccessToken
|
4
|
+
def oauth2_access_token
|
5
|
+
access_token_response = client.request(access_token_method, access_token_url, headers: access_token_headers, parse: :json).parsed
|
6
|
+
|
7
|
+
hash = {
|
8
|
+
:access_token => access_token_response["access_token"],
|
9
|
+
:expires_in => access_token_response["expires_in"],
|
10
|
+
}
|
11
|
+
|
12
|
+
::OAuth2::AccessToken.from_hash(client, hash)
|
13
|
+
end
|
14
|
+
|
15
|
+
def get_user_info
|
16
|
+
@raw_info ||= JSON.load(access_token.get("https://graph.zalo.me/v2.0/me?access_token=#{access_token.token}&fields=id,birthday,name,gender,picture,phone").body)
|
17
|
+
rescue ::Errno::ETIMEDOUT
|
18
|
+
raise ::Timeout::Error
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def access_token_method
|
24
|
+
options.client_options.token_method
|
25
|
+
end
|
26
|
+
|
27
|
+
def access_token_headers
|
28
|
+
{ "secret_key" => options.client_secret }
|
29
|
+
end
|
30
|
+
|
31
|
+
def access_token_url
|
32
|
+
client.token_url(access_token_params)
|
33
|
+
end
|
34
|
+
|
35
|
+
def access_token_params
|
36
|
+
{}.tap do |params|
|
37
|
+
params[:redirect_uri] = callback_url
|
38
|
+
params[:app_id] = options.client_id
|
39
|
+
params[:code] = request.params['code']
|
40
|
+
params[:code_verifier] = options.client_options.code_verifier
|
41
|
+
params[:grant_type] = options.client_options.grant_type
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -4,13 +4,18 @@ require 'json'
|
|
4
4
|
module OmniAuth
|
5
5
|
module Strategies
|
6
6
|
class Zalo < OmniAuth::Strategies::OAuth2
|
7
|
+
include BuildAccessToken
|
8
|
+
|
7
9
|
option :name, 'zalo'
|
8
10
|
|
9
11
|
option :client_options, {
|
10
12
|
site: 'https://oauth.zaloapp.com',
|
11
|
-
authorize_url: '/
|
12
|
-
token_url: '/
|
13
|
-
token_method: :
|
13
|
+
authorize_url: '/v4/permission',
|
14
|
+
token_url: '/v4/access_token',
|
15
|
+
token_method: :post,
|
16
|
+
grant_type: 'authorization_code',
|
17
|
+
code_challenge: 'is5SvnFPQzBNP-nb-poEaFlsvK1a6S3NpVCz0vcHh0w',
|
18
|
+
code_verifier: 'h57bycdwryntewreomnbSyDrAG4kX7BeqS7g-luzvBE'
|
14
19
|
}
|
15
20
|
|
16
21
|
option :provider_ignores_state, true
|
@@ -25,17 +30,15 @@ module OmniAuth
|
|
25
30
|
end
|
26
31
|
|
27
32
|
def authorize_params
|
28
|
-
super.merge(app_id: self.options.client_id)
|
33
|
+
super.merge(app_id: self.options.client_id, code_challenge: options.client_options.code_challenge)
|
29
34
|
end
|
30
35
|
|
31
36
|
def build_access_token
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
}
|
38
|
-
::OAuth2::AccessToken.from_hash(client, hash)
|
37
|
+
oauth2_access_token
|
38
|
+
end
|
39
|
+
|
40
|
+
def raw_info
|
41
|
+
get_user_info
|
39
42
|
end
|
40
43
|
|
41
44
|
alias :old_callback_url :callback_url
|
@@ -47,12 +50,6 @@ module OmniAuth
|
|
47
50
|
old_callback_url
|
48
51
|
end
|
49
52
|
end
|
50
|
-
|
51
|
-
def raw_info
|
52
|
-
@raw_info ||= JSON.load(access_token.get("https://graph.zalo.me/v2.0/me?access_token=#{access_token.token}&fields=id,birthday,name,gender,picture,phone").body)
|
53
|
-
rescue ::Errno::ETIMEDOUT
|
54
|
-
raise ::Timeout::Error
|
55
|
-
end
|
56
53
|
end
|
57
54
|
end
|
58
55
|
end
|
data/lib/omniauth/zalo.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniauth-zalo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- nguyenthanhcong101096
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-08-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -74,20 +74,16 @@ files:
|
|
74
74
|
- Rakefile
|
75
75
|
- bin/console
|
76
76
|
- bin/setup
|
77
|
+
- lib/omniauth/strategies/build_access_token.rb
|
77
78
|
- lib/omniauth/strategies/zalo.rb
|
78
79
|
- lib/omniauth/zalo.rb
|
79
|
-
- lib/omniauth/zalo/oauth.rb
|
80
80
|
- lib/omniauth/zalo/version.rb
|
81
|
-
- omniauth-zalo-0.1.0.gem
|
82
|
-
- omniauth-zalo-0.1.1.gem
|
83
|
-
- omniauth-zalo-0.1.2.gem
|
84
|
-
- omniauth-zalo-0.1.3.gem
|
85
81
|
- omniauth-zalo.gemspec
|
86
82
|
homepage: https://github.com/nguyenthanhcong101096/omniauth-zalo
|
87
83
|
licenses:
|
88
84
|
- Apache-2.0
|
89
85
|
metadata: {}
|
90
|
-
post_install_message:
|
86
|
+
post_install_message:
|
91
87
|
rdoc_options: []
|
92
88
|
require_paths:
|
93
89
|
- lib
|
@@ -102,9 +98,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
102
98
|
- !ruby/object:Gem::Version
|
103
99
|
version: '0'
|
104
100
|
requirements: []
|
105
|
-
|
106
|
-
|
107
|
-
signing_key:
|
101
|
+
rubygems_version: 3.1.6
|
102
|
+
signing_key:
|
108
103
|
specification_version: 4
|
109
104
|
summary: this is the all module for wakuwaku appkication
|
110
105
|
test_files: []
|
data/lib/omniauth/zalo/oauth.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
# module Omniauth
|
2
|
-
# class Zalo::Oauth
|
3
|
-
# attr_reader :app_id, :app_secret, :redirect_uri, :state
|
4
|
-
|
5
|
-
# # client_options = {
|
6
|
-
# # site: 'https://oauth.zaloapp.com',
|
7
|
-
# # authorize_url: "/v3/auth?app_id=#{app_id}&redirect_uri=#{redirect_uri}&state=#{state}",
|
8
|
-
# # access_token_url: "/v3/access_token?app_id=#{app_id}&app_secret=#{app_secret}&code=#{code}",
|
9
|
-
# # account_info_url: "https://graph.zalo.me/v2.0/me?access_token=#{token}&fields=id,birthday,name,gender,picture,phone"
|
10
|
-
# # }
|
11
|
-
|
12
|
-
# def initialize(app_id, app_secret, redirect_uri)
|
13
|
-
# @app_id = app_id
|
14
|
-
# @app_secret = app_secret
|
15
|
-
# @redirect_uri = redirect_uri
|
16
|
-
# @state = state_hex
|
17
|
-
# end
|
18
|
-
|
19
|
-
# private
|
20
|
-
|
21
|
-
# def state_hex
|
22
|
-
# SecureRandom.hex
|
23
|
-
# end
|
24
|
-
# end
|
25
|
-
# end
|
data/omniauth-zalo-0.1.0.gem
DELETED
Binary file
|
data/omniauth-zalo-0.1.1.gem
DELETED
Binary file
|
data/omniauth-zalo-0.1.2.gem
DELETED
Binary file
|
data/omniauth-zalo-0.1.3.gem
DELETED
Binary file
|