zoom_rb 1.0.2 → 1.1.0
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 +4 -4
- data/CHANGELOG.md +7 -0
- data/Gemfile.lock +1 -1
- data/lib/zoom/actions/token.rb +12 -6
- data/lib/zoom/actions.rb +14 -5
- data/lib/zoom/client.rb +10 -4
- data/lib/zoom/clients/oauth.rb +9 -3
- data/lib/zoom/version.rb +1 -1
- data/spec/fixtures/token/revoke_token.json +3 -0
- data/spec/lib/zoom/actions/token/access_token_spec.rb +34 -8
- data/spec/lib/zoom/actions/token/data_compliance_spec.rb +6 -1
- data/spec/lib/zoom/actions/token/refresh_token_spec.rb +33 -8
- data/spec/lib/zoom/actions/token/revoke_token_spec.rb +52 -0
- data/spec/lib/zoom/actions_spec.rb +14 -2
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f1daca097d96a5590a12307f6fb353a613e8c74ae5c0a0ab93fde738fcd3518b
|
4
|
+
data.tar.gz: 33bbfbb55bb2343c296cddfd92906b799fd57ded467f7755e836971b58f675ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c02b9b0964774320e19da1a8269e864c012b86ea32e4383d1e69618dc6d6a2e927fb263782009c199a57003c3b11b6c928b3d5945a955df8aaf4050fabd0721
|
7
|
+
data.tar.gz: a5b0c0c8ae5d8c59e30967a4b48e1372dccd0642dd90a5bc8551b917b0a91f8a912dfe2a4c056caae6659ac477812cfd79b745659ac361b63649edbc2a163c86
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
# 1.1.0
|
2
|
+
|
3
|
+
### New features
|
4
|
+
* Support the new Zoom API OAuth security measures which are described here:
|
5
|
+
https://marketplace.zoom.us/docs/guides/stay-up-to-date/announcements/#zoom-oauth-security-updates
|
6
|
+
* Support the code_verifier parameter in the access_tokens call.
|
7
|
+
|
1
8
|
# 1.0.2
|
2
9
|
|
3
10
|
### Fixes:
|
data/Gemfile.lock
CHANGED
data/lib/zoom/actions/token.rb
CHANGED
@@ -6,12 +6,16 @@ module Zoom
|
|
6
6
|
extend Zoom::Actions
|
7
7
|
|
8
8
|
post 'access_tokens',
|
9
|
-
'/oauth/token
|
10
|
-
oauth: true
|
9
|
+
'/oauth/token',
|
10
|
+
oauth: true,
|
11
|
+
require: %i[grant_type code redirect_uri],
|
12
|
+
permit: :code_verifier,
|
13
|
+
args_to_params: { auth_code: :code }
|
11
14
|
|
12
15
|
post 'refresh_tokens',
|
13
|
-
'/oauth/token
|
14
|
-
oauth: true
|
16
|
+
'/oauth/token',
|
17
|
+
oauth: true,
|
18
|
+
require: %i[grant_type refresh_token]
|
15
19
|
|
16
20
|
post 'data_compliance', '/oauth/data/compliance',
|
17
21
|
oauth: true,
|
@@ -19,8 +23,10 @@ module Zoom
|
|
19
23
|
client_id user_id account_id deauthorization_event_received compliance_completed
|
20
24
|
]
|
21
25
|
|
22
|
-
post 'revoke_tokens', '/oauth/revoke
|
23
|
-
oauth: true
|
26
|
+
post 'revoke_tokens', '/oauth/revoke',
|
27
|
+
oauth: true,
|
28
|
+
require: :token,
|
29
|
+
args_to_params: { access_token: :token }
|
24
30
|
end
|
25
31
|
end
|
26
32
|
end
|
data/lib/zoom/actions.rb
CHANGED
@@ -26,31 +26,40 @@ module Zoom
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
def self.make_request(
|
29
|
+
def self.make_request(args)
|
30
|
+
client, method, parsed_path, params, request_options, oauth =
|
31
|
+
args.values_at :client, :method, :parsed_path, :params, :request_options, :oauth
|
30
32
|
case method
|
31
33
|
when :get
|
32
34
|
request_options[:query] = params
|
33
35
|
when :post, :put, :patch
|
34
|
-
request_options[:body] =
|
36
|
+
request_options[:body] =
|
37
|
+
oauth ? URI.encode_www_form(params.to_a) : params.to_json
|
35
38
|
end
|
36
39
|
client.class.public_send(method, parsed_path, **request_options)
|
37
40
|
end
|
38
41
|
|
39
42
|
[:get, :post, :patch, :put, :delete].each do |method|
|
40
43
|
define_method(method) do |name, path, options={}|
|
41
|
-
required, permitted, oauth
|
44
|
+
required, permitted, oauth, args_to_params, headers =
|
45
|
+
options.values_at :require, :permit, :oauth, :args_to_params, :headers
|
42
46
|
required = Array(required) unless required.is_a?(Hash)
|
43
47
|
permitted = Array(permitted) unless permitted.is_a?(Hash)
|
44
48
|
|
45
49
|
define_method(name) do |*args|
|
46
50
|
path_keys = Zoom::Actions.extract_path_keys(path)
|
47
|
-
params =
|
51
|
+
params = Utils.extract_options!(args)
|
52
|
+
args_to_params&.each { |key, value| params[value] = params.delete key if params[key] }
|
53
|
+
params = Zoom::Params.new(params)
|
48
54
|
parsed_path = Zoom::Actions.parse_path(path, path_keys, params)
|
49
55
|
request_options = Zoom::Actions.determine_request_options(self, oauth)
|
50
56
|
params = params.require(path_keys) unless path_keys.empty?
|
51
57
|
params_without_required = required.empty? ? params : params.require(required)
|
52
58
|
params_without_required.permit(permitted) unless permitted.empty?
|
53
|
-
response = Zoom::Actions.make_request(
|
59
|
+
response = Zoom::Actions.make_request({
|
60
|
+
client: self, method: method, parsed_path: parsed_path,
|
61
|
+
params: params, request_options: request_options, oauth: oauth
|
62
|
+
})
|
54
63
|
Utils.parse_response(response)
|
55
64
|
end
|
56
65
|
end
|
data/lib/zoom/client.rb
CHANGED
@@ -35,14 +35,20 @@ module Zoom
|
|
35
35
|
|
36
36
|
def oauth_request_headers
|
37
37
|
{
|
38
|
-
'Authorization' => "Basic #{auth_token}"
|
39
|
-
|
38
|
+
'Authorization' => "Basic #{auth_token}",
|
39
|
+
'Accept' => 'application/json',
|
40
|
+
'Content-Type' => 'application/x-www-form-urlencoded',
|
41
|
+
}
|
40
42
|
end
|
41
43
|
|
42
|
-
def
|
44
|
+
def bearer_authorization_header
|
43
45
|
{
|
44
46
|
'Authorization' => "Bearer #{access_token}"
|
45
|
-
}
|
47
|
+
}
|
48
|
+
end
|
49
|
+
|
50
|
+
def request_headers
|
51
|
+
bearer_authorization_header.merge(headers)
|
46
52
|
end
|
47
53
|
|
48
54
|
def auth_token
|
data/lib/zoom/clients/oauth.rb
CHANGED
@@ -13,7 +13,7 @@ module Zoom
|
|
13
13
|
# Returns (access_token, refresh_token)
|
14
14
|
#
|
15
15
|
def initialize(config)
|
16
|
-
Zoom::Params.new(config).permit( %i[auth_token auth_code redirect_uri access_token refresh_token timeout])
|
16
|
+
Zoom::Params.new(config).permit( %i[auth_token auth_code redirect_uri access_token refresh_token timeout code_verifier])
|
17
17
|
Zoom::Params.new(config).require_one_of(%i[access_token refresh_token auth_code])
|
18
18
|
if (config.keys & [:auth_code, :redirect_uri]).any?
|
19
19
|
Zoom::Params.new(config).require( %i[auth_code redirect_uri])
|
@@ -28,13 +28,19 @@ module Zoom
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def refresh
|
31
|
-
response = refresh_tokens(refresh_token: @refresh_token)
|
31
|
+
response = refresh_tokens(grant_type: 'refresh_token', refresh_token: @refresh_token)
|
32
32
|
set_tokens(response)
|
33
33
|
response
|
34
34
|
end
|
35
35
|
|
36
36
|
def oauth
|
37
|
-
response = access_tokens(
|
37
|
+
response = access_tokens(
|
38
|
+
grant_type: 'authorization_code',
|
39
|
+
auth_code: @auth_code,
|
40
|
+
redirect_uri: @redirect_uri,
|
41
|
+
code_verifier: @code_verifier
|
42
|
+
)
|
43
|
+
|
38
44
|
set_tokens(response)
|
39
45
|
response
|
40
46
|
end
|
data/lib/zoom/version.rb
CHANGED
@@ -4,23 +4,49 @@ require 'spec_helper'
|
|
4
4
|
|
5
5
|
describe Zoom::Actions::Token do
|
6
6
|
let(:zc) { oauth_client }
|
7
|
-
let(:args) { { auth_code: 'xxx', redirect_uri: 'http://localhost:3000' } }
|
7
|
+
let(:args) { { grant_type: 'authorization_code', auth_code: 'xxx', redirect_uri: 'http://localhost:3000', code_verifier: 'xxx' } }
|
8
|
+
let(:body) { { grant_type: 'authorization_code', redirect_uri: 'http://localhost:3000', code_verifier: 'xxx', code: 'xxx' } }
|
8
9
|
|
9
10
|
describe '#access_tokens action' do
|
11
|
+
let(:path) { '/oauth/token' }
|
12
|
+
|
13
|
+
let(:params) do
|
14
|
+
{
|
15
|
+
base_uri: 'https://zoom.us/',
|
16
|
+
body: URI.encode_www_form(body.to_a),
|
17
|
+
headers: {
|
18
|
+
'Accept'=>'application/json',
|
19
|
+
'Authorization'=>'Basic eHh4Onh4eA==',
|
20
|
+
'Content-Type'=>'application/x-www-form-urlencoded'
|
21
|
+
}
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
10
25
|
before :each do
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
26
|
+
Zoom.configure do |config|
|
27
|
+
config.api_key = 'xxx'
|
28
|
+
config.api_secret = 'xxx'
|
29
|
+
end
|
30
|
+
|
31
|
+
allow(Zoom::Utils).to receive(:parse_response).and_return(code: 200)
|
32
|
+
allow(Zoom::Client::OAuth).to(
|
33
|
+
receive(:post).with(path, params)
|
34
|
+
.and_return(body: json_response('token', 'access_token'),
|
35
|
+
headers: { 'Content-Type' => 'application/json' })
|
36
|
+
)
|
16
37
|
end
|
17
38
|
|
18
|
-
it "
|
19
|
-
expect { zc.access_tokens }.to raise_error(Zoom::ParameterMissing, [:
|
39
|
+
it "raises an error when args missing" do
|
40
|
+
expect { zc.access_tokens }.to raise_error(Zoom::ParameterMissing, [:grant_type, :code, :redirect_uri].to_s)
|
20
41
|
end
|
21
42
|
|
22
43
|
it 'returns a hash' do
|
23
44
|
expect(zc.access_tokens(args)).to be_kind_of(Hash)
|
24
45
|
end
|
46
|
+
|
47
|
+
it 'passes args in the body and sends x-www-form-urlencoded header' do
|
48
|
+
zc.access_tokens(args)
|
49
|
+
expect(Zoom::Client::OAuth).to have_received(:post).with(path, params)
|
50
|
+
end
|
25
51
|
end
|
26
52
|
end
|
@@ -23,6 +23,11 @@ describe Zoom::Actions::Token do
|
|
23
23
|
|
24
24
|
describe '#data_compliance action' do
|
25
25
|
before :each do
|
26
|
+
Zoom.configure do |config|
|
27
|
+
config.api_key = 'xxx'
|
28
|
+
config.api_secret = 'xxx'
|
29
|
+
end
|
30
|
+
|
26
31
|
stub_request(
|
27
32
|
:post,
|
28
33
|
zoom_auth_url('oauth/data/compliance')
|
@@ -30,7 +35,7 @@ describe Zoom::Actions::Token do
|
|
30
35
|
headers: { 'Content-Type' => 'application/json' })
|
31
36
|
end
|
32
37
|
|
33
|
-
it "
|
38
|
+
it "raises an error when args missing" do
|
34
39
|
expect { zc.data_compliance }.to raise_error(Zoom::ParameterMissing, [:client_id, :user_id, :account_id, :deauthorization_event_received, :compliance_completed].to_s)
|
35
40
|
end
|
36
41
|
|
@@ -4,23 +4,48 @@ require 'spec_helper'
|
|
4
4
|
|
5
5
|
describe Zoom::Actions::Token do
|
6
6
|
let(:zc) { oauth_client }
|
7
|
-
let(:args) { { refresh_token: 'xxx' } }
|
7
|
+
let(:args) { { grant_type: 'refresh_token', refresh_token: 'xxx' } }
|
8
8
|
|
9
9
|
describe '#refresh_tokens action' do
|
10
|
+
let(:path) { '/oauth/token' }
|
11
|
+
|
12
|
+
let(:params) do
|
13
|
+
{
|
14
|
+
base_uri: 'https://zoom.us/',
|
15
|
+
body: URI.encode_www_form(args.to_a),
|
16
|
+
headers: {
|
17
|
+
'Accept'=>'application/json',
|
18
|
+
'Authorization'=>'Basic eHh4Onh4eA==',
|
19
|
+
'Content-Type'=>'application/x-www-form-urlencoded'
|
20
|
+
}
|
21
|
+
}
|
22
|
+
end
|
23
|
+
|
10
24
|
before :each do
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
25
|
+
Zoom.configure do |config|
|
26
|
+
config.api_key = 'xxx'
|
27
|
+
config.api_secret = 'xxx'
|
28
|
+
end
|
29
|
+
|
30
|
+
allow(Zoom::Utils).to receive(:parse_response).and_return(code: 200)
|
31
|
+
allow(Zoom::Client::OAuth).to(
|
32
|
+
receive(:post).with(path, params)
|
33
|
+
.and_return(body: json_response('token', 'access_token'),
|
34
|
+
headers: { 'Content-Type' => 'application/json' })
|
35
|
+
)
|
16
36
|
end
|
17
37
|
|
18
|
-
it "
|
19
|
-
expect { zc.refresh_tokens }.to raise_error(Zoom::ParameterMissing, [:refresh_token].to_s)
|
38
|
+
it "raises an error when args missing" do
|
39
|
+
expect { zc.refresh_tokens }.to raise_error(Zoom::ParameterMissing, [:grant_type, :refresh_token].to_s)
|
20
40
|
end
|
21
41
|
|
22
42
|
it 'returns a hash' do
|
23
43
|
expect(zc.refresh_tokens(args)).to be_kind_of(Hash)
|
24
44
|
end
|
45
|
+
|
46
|
+
it 'passes args in the body and sends x-www-form-urlencoded header' do
|
47
|
+
zc.refresh_tokens(args)
|
48
|
+
expect(Zoom::Client::OAuth).to have_received(:post).with(path, params)
|
49
|
+
end
|
25
50
|
end
|
26
51
|
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Zoom::Actions::Token do
|
6
|
+
let(:zc) { oauth_client }
|
7
|
+
let(:args) { { access_token: 'xxx' } }
|
8
|
+
let(:body) { { token: 'xxx' } }
|
9
|
+
|
10
|
+
describe '#revoke_tokens action' do
|
11
|
+
let(:path) { '/oauth/revoke' }
|
12
|
+
|
13
|
+
let(:params) do
|
14
|
+
{
|
15
|
+
base_uri: 'https://zoom.us/',
|
16
|
+
body: URI.encode_www_form(body.to_a),
|
17
|
+
headers: {
|
18
|
+
'Accept'=>'application/json',
|
19
|
+
'Authorization'=>'Basic eHh4Onh4eA==',
|
20
|
+
'Content-Type'=>'application/x-www-form-urlencoded'
|
21
|
+
}
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
25
|
+
before :each do
|
26
|
+
Zoom.configure do |config|
|
27
|
+
config.api_key = 'xxx'
|
28
|
+
config.api_secret = 'xxx'
|
29
|
+
end
|
30
|
+
|
31
|
+
allow(Zoom::Utils).to receive(:parse_response).and_return(code: 200)
|
32
|
+
allow(Zoom::Client::OAuth).to(
|
33
|
+
receive(:post).with(path, params)
|
34
|
+
.and_return(body: json_response('token', 'access_token'),
|
35
|
+
headers: { 'Content-Type' => 'application/json' })
|
36
|
+
)
|
37
|
+
end
|
38
|
+
|
39
|
+
it "raises an error when args missing" do
|
40
|
+
expect { zc.revoke_tokens }.to raise_error(Zoom::ParameterMissing, [:token].to_s)
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'returns a hash' do
|
44
|
+
expect(zc.revoke_tokens(args)).to be_kind_of(Hash)
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'passes args in the body and sends x-www-form-urlencoded header' do
|
48
|
+
zc.revoke_tokens(args)
|
49
|
+
expect(Zoom::Client::OAuth).to have_received(:post).with(path, params)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -12,7 +12,7 @@ describe Zoom::Actions do
|
|
12
12
|
|
13
13
|
describe 'self.extract_path_keys' do
|
14
14
|
subject { described_class.extract_path_keys(path) }
|
15
|
-
|
15
|
+
|
16
16
|
it { is_expected.to match_array(path_keys) }
|
17
17
|
end
|
18
18
|
|
@@ -23,10 +23,22 @@ describe Zoom::Actions do
|
|
23
23
|
end
|
24
24
|
|
25
25
|
describe 'self.make_request' do
|
26
|
-
subject
|
26
|
+
subject do
|
27
|
+
described_class.make_request({
|
28
|
+
client: client, method: method, parsed_path: parsed_path,
|
29
|
+
params: params, request_options: request_options
|
30
|
+
})
|
31
|
+
end
|
27
32
|
|
28
33
|
let(:request_options) { Zoom::Actions.determine_request_options(client, oauth) }
|
29
34
|
|
35
|
+
before :each do
|
36
|
+
Zoom.configure do |config|
|
37
|
+
config.api_key = 'xxx'
|
38
|
+
config.api_secret = 'xxx'
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
30
42
|
context 'when get' do
|
31
43
|
let(:method) { :get }
|
32
44
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zoom_rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kyle Boe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-02-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -266,6 +266,7 @@ files:
|
|
266
266
|
- spec/fixtures/token/access_token.json
|
267
267
|
- spec/fixtures/token/data_compliance.json
|
268
268
|
- spec/fixtures/token/refresh_token.json
|
269
|
+
- spec/fixtures/token/revoke_token.json
|
269
270
|
- spec/fixtures/user/assistant/create.json
|
270
271
|
- spec/fixtures/user/assistant/list.json
|
271
272
|
- spec/fixtures/user/assistant/set.json
|
@@ -395,6 +396,7 @@ files:
|
|
395
396
|
- spec/lib/zoom/actions/token/access_token_spec.rb
|
396
397
|
- spec/lib/zoom/actions/token/data_compliance_spec.rb
|
397
398
|
- spec/lib/zoom/actions/token/refresh_token_spec.rb
|
399
|
+
- spec/lib/zoom/actions/token/revoke_token_spec.rb
|
398
400
|
- spec/lib/zoom/actions/user/assistant/create_spec.rb
|
399
401
|
- spec/lib/zoom/actions/user/assistant/delete_all_spec.rb
|
400
402
|
- spec/lib/zoom/actions/user/assistant/delete_spec.rb
|
@@ -544,6 +546,7 @@ test_files:
|
|
544
546
|
- spec/fixtures/token/access_token.json
|
545
547
|
- spec/fixtures/token/data_compliance.json
|
546
548
|
- spec/fixtures/token/refresh_token.json
|
549
|
+
- spec/fixtures/token/revoke_token.json
|
547
550
|
- spec/fixtures/user/assistant/create.json
|
548
551
|
- spec/fixtures/user/assistant/list.json
|
549
552
|
- spec/fixtures/user/assistant/set.json
|
@@ -673,6 +676,7 @@ test_files:
|
|
673
676
|
- spec/lib/zoom/actions/token/access_token_spec.rb
|
674
677
|
- spec/lib/zoom/actions/token/data_compliance_spec.rb
|
675
678
|
- spec/lib/zoom/actions/token/refresh_token_spec.rb
|
679
|
+
- spec/lib/zoom/actions/token/revoke_token_spec.rb
|
676
680
|
- spec/lib/zoom/actions/user/assistant/create_spec.rb
|
677
681
|
- spec/lib/zoom/actions/user/assistant/delete_all_spec.rb
|
678
682
|
- spec/lib/zoom/actions/user/assistant/delete_spec.rb
|