omniauth-zooming 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/Gemfile +4 -0
- data/Guardfile +11 -0
- data/LICENSE +19 -0
- data/README.md +45 -0
- data/Rakefile +8 -0
- data/lib/omniauth-zooming.rb +2 -0
- data/lib/omniauth-zooming/version.rb +5 -0
- data/lib/omniauth/strategies/zoom.rb +51 -0
- data/omniauth-zooming.gemspec +25 -0
- data/spec/omniauth/strategies/zoom_spec.rb +34 -0
- data/spec/spec_helper.rb +15 -0
- data/spec/support/shared_examples.rb +40 -0
- metadata +143 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d3f92d270b9ab2d107fb46fda08d5bead0c147e35ee218f0e3682ee14ab3ad29
|
4
|
+
data.tar.gz: 348559bc24790e3754d20bfb2170897f40cc1e49e6dfb4dba98ae90c8b6e9899
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e877f5ffa558c98e11fa58e9c5bfbb97eae4feae630e1199b4f1a79df7873f167aabd0c68e961310a466c27c8b30f466afb4d19e88f822e18c6291ead2187244
|
7
|
+
data.tar.gz: 19abb42dc422b7c5f0bcc30739748aebcd82e8cf37b6223ebb19cef4b7ad4dbe812ca6f3eb7125f2b6ea3580f535052f5b20a8fd58ab05d88792a394520d12ab
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Guardfile
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
guard 'rspec', :version => 2 do
|
2
|
+
watch(%r{^spec/.+_spec\.rb$})
|
3
|
+
watch(%r{^spec/support/.+\.rb$})
|
4
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
5
|
+
watch('spec/spec_helper.rb') { "spec" }
|
6
|
+
end
|
7
|
+
|
8
|
+
guard 'bundler' do
|
9
|
+
watch('Gemfile')
|
10
|
+
watch('omniauth-zooming.gemspec')
|
11
|
+
end
|
data/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2017 Espen Antonsen
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
11
|
+
copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# OmniAuth zoom
|
2
|
+
|
3
|
+
This gem contains the unofficial Zoom strategy for OmniAuth.
|
4
|
+
|
5
|
+
See the [authorization documentation](https://marketplace.zoom.us/docs/guides/auth/oauth) for Zoom.
|
6
|
+
|
7
|
+
For more information about the API see https://marketplace.zoom.us/docs/api-reference/introduction.
|
8
|
+
|
9
|
+
## Basic Usage
|
10
|
+
|
11
|
+
use OmniAuth::Builder do
|
12
|
+
provider :zoom, ENV['ZOOM_CLIENT_ID'], ENV['ZOOM_CLIENT_SECRET']
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
## Refreshing the access token
|
17
|
+
|
18
|
+
The retrieved ```access_token``` expires in one hour. So you need to retrieve a new token when it expires. You can do so using the ```refresh!``` method in OmniAuth. You will retrieve all new tokens so make sure you save both the ```access_token``` and ```refresh_token```.
|
19
|
+
|
20
|
+
Example:
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
if Time.at( zoom_access_token_expires_at ).past?
|
24
|
+
oauth = OmniAuth::Strategies::Zoom.new(nil, {
|
25
|
+
client_id: ENV['zoom_CLIENT_ID'],
|
26
|
+
client_secret: ENV['zoom_CLIENT_SECRET']
|
27
|
+
}
|
28
|
+
token = OAuth2::AccessToken.new(
|
29
|
+
oauth.client,
|
30
|
+
zoom_access_token,
|
31
|
+
{ refresh_token: zoom_refresh_token }
|
32
|
+
)
|
33
|
+
new_tokens = token.refresh!
|
34
|
+
end
|
35
|
+
```
|
36
|
+
|
37
|
+
You can then use the new ```access_token``` and when it expires you can use the new ```refresh_token``` to gain a new one.
|
38
|
+
|
39
|
+
## Credits
|
40
|
+
|
41
|
+
Based on [omniauth-37signals](https://github.com/tallgreentree/omniauth-37signals) by [Will Barrett](https://github.com/willbarrett).
|
42
|
+
|
43
|
+
## License
|
44
|
+
|
45
|
+
Copyright (c) 2017 by Espen Antonsen. [MIT License](LICENSE)
|
data/Rakefile
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'omniauth-oauth2'
|
2
|
+
require 'multi_json'
|
3
|
+
|
4
|
+
module OmniAuth
|
5
|
+
module Strategies
|
6
|
+
class Zoom < OmniAuth::Strategies::OAuth2
|
7
|
+
option :name, "zoom"
|
8
|
+
option :provider_ignores_state, true
|
9
|
+
option :client_options, {
|
10
|
+
token_url: "https://zoom.us/oauth/token",
|
11
|
+
authorize_url: "https://zoom.us/oauth/authorize",
|
12
|
+
site: "https://zoom.us"
|
13
|
+
}
|
14
|
+
|
15
|
+
info do
|
16
|
+
{
|
17
|
+
:name => raw_info['Name'],
|
18
|
+
:email => raw_info['Email']
|
19
|
+
}
|
20
|
+
end
|
21
|
+
|
22
|
+
extra do
|
23
|
+
{
|
24
|
+
'raw_info' => raw_info
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
28
|
+
credentials do
|
29
|
+
hash = {'token' => access_token.token}
|
30
|
+
hash.merge!('refresh_token' => access_token.refresh_token) if access_token.refresh_token
|
31
|
+
hash.merge!('expires_at' => access_token.expires_at ) if access_token.expires?
|
32
|
+
hash.merge!('expires' => access_token.expires?)
|
33
|
+
hash
|
34
|
+
end
|
35
|
+
|
36
|
+
def raw_info
|
37
|
+
@raw_info ||= access_token.get('/v2/users/me').parsed
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def callback_url
|
43
|
+
full_host + script_name + callback_path
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
OmniAuth.config.add_camelization 'zoom', 'Zoom'
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/omniauth-zooming/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Espen Antonsen"]
|
6
|
+
gem.email = ["espen@inspired.no"]
|
7
|
+
gem.description = %q{OmniAuth strategy for Zoom.}
|
8
|
+
gem.summary = %q{OmniAuth strategy for Zoom.}
|
9
|
+
gem.homepage = "https://github.com/espen/omniauth-zooming"
|
10
|
+
gem.license = 'MIT'
|
11
|
+
|
12
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
13
|
+
gem.files = `git ls-files`.split("\n")
|
14
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
15
|
+
gem.name = "omniauth-zooming"
|
16
|
+
gem.require_paths = ["lib"]
|
17
|
+
gem.version = OmniAuth::Zoom::VERSION
|
18
|
+
|
19
|
+
gem.add_dependency 'omniauth', '~> 1.0'
|
20
|
+
gem.add_dependency 'omniauth-oauth2', '~> 1.0'
|
21
|
+
gem.add_development_dependency 'rspec'
|
22
|
+
gem.add_development_dependency 'rack-test'
|
23
|
+
gem.add_development_dependency 'webmock'
|
24
|
+
gem.add_development_dependency "rake"
|
25
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'omniauth-zooming'
|
3
|
+
|
4
|
+
describe OmniAuth::Strategies::Zoom do
|
5
|
+
subject do
|
6
|
+
strategy = OmniAuth::Strategies::Zoom.new(nil, @options || {})
|
7
|
+
strategy.stub(:session) { {} }
|
8
|
+
strategy
|
9
|
+
end
|
10
|
+
|
11
|
+
it_should_behave_like 'an oauth2 strategy'
|
12
|
+
|
13
|
+
describe '#client' do
|
14
|
+
it 'should have the correct zoom site' do
|
15
|
+
subject.client.site.should eq("https://zoom.us")
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should have the correct authorization url' do
|
19
|
+
subject.client.options[:authorize_url].should eq("https://zoom.us/oauth/authorize")
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'should have the correct token url' do
|
23
|
+
subject.client.options[:token_url].should eq('https://zoom.us/oauth/token')
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
describe '#callback_path' do
|
29
|
+
it 'should have the correct callback path' do
|
30
|
+
subject.callback_path.should eq('/auth/zoom/callback')
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
$:.unshift File.expand_path('..', __FILE__)
|
2
|
+
$:.unshift File.expand_path('../../lib', __FILE__)
|
3
|
+
|
4
|
+
require 'rspec'
|
5
|
+
require 'rack/test'
|
6
|
+
require 'omniauth'
|
7
|
+
require 'omniauth-zooming'
|
8
|
+
|
9
|
+
Dir[File.expand_path('../support/**/*', __FILE__)].each { |f| require f }
|
10
|
+
|
11
|
+
RSpec.configure do |config|
|
12
|
+
config.include Rack::Test::Methods
|
13
|
+
config.extend OmniAuth::Test::StrategyMacros, :type => :strategy
|
14
|
+
end
|
15
|
+
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# NOTE it would be useful if this lived in omniauth-oauth2 eventually
|
2
|
+
# Thanks to Josh Ellithorpe for this file -Will
|
3
|
+
|
4
|
+
shared_examples 'an oauth2 strategy' do
|
5
|
+
describe '#client' do
|
6
|
+
it 'should be initialized with symbolized client_options' do
|
7
|
+
@options = { :client_options => { 'authorize_url' => 'https://example.com' } }
|
8
|
+
subject.client.options[:authorize_url].should == 'https://example.com'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '#authorize_params' do
|
13
|
+
it 'should include any authorize params passed in the :authorize_params option' do
|
14
|
+
@options = { :authorize_params => { :foo => 'bar', :baz => 'zip' } }
|
15
|
+
subject.authorize_params['foo'].should eq('bar')
|
16
|
+
subject.authorize_params['baz'].should eq('zip')
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'should include top-level options that are marked as :authorize_options' do
|
20
|
+
@options = { :authorize_options => [:scope, :foo], :scope => 'bar', :foo => 'baz' }
|
21
|
+
subject.authorize_params['scope'].should eq('bar')
|
22
|
+
subject.authorize_params['foo'].should eq('baz')
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '#token_params' do
|
27
|
+
it 'should include any token params passed in the :token_params option' do
|
28
|
+
@options = { :token_params => { :foo => 'bar', :baz => 'zip' } }
|
29
|
+
subject.token_params['foo'].should eq('bar')
|
30
|
+
subject.token_params['baz'].should eq('zip')
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should include top-level options that are marked as :token_options' do
|
34
|
+
@options = { :token_options => [:scope, :foo], :scope => 'bar', :foo => 'baz' }
|
35
|
+
subject.token_params['scope'].should eq('bar')
|
36
|
+
subject.token_params['foo'].should eq('baz')
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
metadata
ADDED
@@ -0,0 +1,143 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-zooming
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Espen Antonsen
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-08-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: omniauth
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: omniauth-oauth2
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rack-test
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: webmock
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rake
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: OmniAuth strategy for Zoom.
|
98
|
+
email:
|
99
|
+
- espen@inspired.no
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- ".gitignore"
|
105
|
+
- Gemfile
|
106
|
+
- Guardfile
|
107
|
+
- LICENSE
|
108
|
+
- README.md
|
109
|
+
- Rakefile
|
110
|
+
- lib/omniauth-zooming.rb
|
111
|
+
- lib/omniauth-zooming/version.rb
|
112
|
+
- lib/omniauth/strategies/zoom.rb
|
113
|
+
- omniauth-zooming.gemspec
|
114
|
+
- spec/omniauth/strategies/zoom_spec.rb
|
115
|
+
- spec/spec_helper.rb
|
116
|
+
- spec/support/shared_examples.rb
|
117
|
+
homepage: https://github.com/espen/omniauth-zooming
|
118
|
+
licenses:
|
119
|
+
- MIT
|
120
|
+
metadata: {}
|
121
|
+
post_install_message:
|
122
|
+
rdoc_options: []
|
123
|
+
require_paths:
|
124
|
+
- lib
|
125
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - ">="
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '0'
|
130
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
131
|
+
requirements:
|
132
|
+
- - ">="
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: '0'
|
135
|
+
requirements: []
|
136
|
+
rubygems_version: 3.2.22
|
137
|
+
signing_key:
|
138
|
+
specification_version: 4
|
139
|
+
summary: OmniAuth strategy for Zoom.
|
140
|
+
test_files:
|
141
|
+
- spec/omniauth/strategies/zoom_spec.rb
|
142
|
+
- spec/spec_helper.rb
|
143
|
+
- spec/support/shared_examples.rb
|