This repository has been archived by the owner on Jun 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from koshilife/develop
release v0.1.0
- Loading branch information
Showing
7 changed files
with
89 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# 0.1.0 | ||
|
||
- Initial release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,6 @@ | |
|
||
module Omniauth | ||
module Zoom | ||
VERSION = '0.0.1' | ||
VERSION = '0.1.0' | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,56 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'base64' | ||
require 'oauth2' | ||
require 'omniauth-oauth2' | ||
|
||
module OmniAuth | ||
module Strategies | ||
class Zoom < OmniAuth::Strategies::OAuth2 | ||
option :name, 'zoom' | ||
option :client_options, site: 'https://zoom.us', | ||
authorize_url: '/oauth/authorize', | ||
token_url: '/oauth/token' | ||
option :client_options, site: 'https://zoom.us' | ||
|
||
uid { raw_info[:id] } | ||
|
||
extra do | ||
{ raw_info: raw_info } | ||
end | ||
|
||
def raw_info | ||
return @raw_info unless @raw_info.nil? | ||
protected | ||
|
||
res = access_token.get '/v2/users/me' | ||
@raw_info = JSON.parse(res.body, symbolize_names: true) | ||
def build_access_token | ||
params = { | ||
grant_type: 'authorization_code', | ||
code: request.params['code'], | ||
redirect_uri: callback_url | ||
} | ||
path = "#{client.options[:token_url]}?#{params.to_query}" | ||
token = Base64.strict_encode64("#{client.id}:#{client.secret}") | ||
opts = { headers: { Authorization: "Basic #{token}" } } | ||
|
||
response = client.request(:post, path, opts) | ||
access_token_opts = response.parsed.merge(deep_symbolize(options.auth_token_params)) | ||
::OAuth2::AccessToken.from_hash(client, access_token_opts).tap do |access_token| | ||
if access_token.respond_to?(:response=) | ||
access_token.response = response | ||
end | ||
end | ||
end | ||
|
||
def callback_url | ||
full_host + script_name + callback_path | ||
end | ||
|
||
def raw_info | ||
return @raw_info unless @raw_info.nil? | ||
|
||
res = access_token.get('/v2/users/me') | ||
@raw_info = JSON.parse(res.body, symbolize_names: true) | ||
rescue StandardError => e | ||
logger = OmniAuth.config.logger | ||
logger&.debug("#{self.class}.#{__method__} #{e.class} occured. message:#{e.message}") | ||
@raw_info = {} | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
require "test_helper" | ||
# frozen_string_literal: true | ||
|
||
require 'test_helper' | ||
|
||
class Omniauth::ZoomTest < Minitest::Test | ||
def test_that_it_has_a_version_number | ||
refute_nil ::Omniauth::Zoom::VERSION | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters