class Zoom::Client::OAuth
Attributes
access_token[R]
expires_at[R]
expires_in[R]
refresh_token[R]
Public Class Methods
new(config)
click to toggle source
Auth_token is sent in the header (auth_code, auth_token, redirect_uri) -> oauth API Returns (access_token
, refresh_token
)
(auth_token, refresh_token
) -> oauth refresh API Returns (access_token
, refresh_token
)
# File lib/zoom/clients/oauth.rb, line 15 def initialize(config) Zoom::Params.new(config).permit( %i[auth_token auth_code redirect_uri access_token refresh_token timeout]) Zoom::Params.new(config).require_one_of(%i[access_token refresh_token auth_code]) if (config.keys & [:auth_code, :redirect_uri]).any? Zoom::Params.new(config).require( %i[auth_code redirect_uri]) end config.each { |k, v| instance_variable_set("@#{k}", v) } self.class.default_timeout(@timeout || 20) end
Public Instance Methods
auth()
click to toggle source
# File lib/zoom/clients/oauth.rb, line 26 def auth refresh_token ? refresh : oauth end
oauth()
click to toggle source
# File lib/zoom/clients/oauth.rb, line 36 def oauth response = access_tokens(auth_code: @auth_code, redirect_uri: @redirect_uri) set_tokens(response) response end
refresh()
click to toggle source
# File lib/zoom/clients/oauth.rb, line 30 def refresh response = refresh_tokens(refresh_token: @refresh_token) set_tokens(response) response end
revoke()
click to toggle source
# File lib/zoom/clients/oauth.rb, line 42 def revoke response = revoke_tokens(access_token: @access_token) set_tokens(response) response end
Private Instance Methods
set_tokens(response)
click to toggle source
# File lib/zoom/clients/oauth.rb, line 50 def set_tokens(response) if response.is_a?(Hash) && !response.key?(:error) @access_token = response["access_token"] @refresh_token = response["refresh_token"] @expires_in = response["expires_in"] @expires_at = @expires_in ? (Time.now + @expires_in).to_i : nil end end