Class: Zoom::Client::OAuth

Inherits:
Zoom::Client show all
Defined in:
lib/zoom/clients/oauth.rb

Constant Summary

Constants included from Actions::Webinar

Actions::Webinar::RECURRENCE_KEYS, Actions::Webinar::SETTINGS_KEYS

Constants included from Actions::Recording

Actions::Recording::RECORDING_SETTINGS_KEYS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Zoom::Client

#auth_token, #bearer_authorization_header, #headers, #oauth_request_headers, #request_headers

Methods included from Actions

determine_request_options, extract_path_keys, make_request, parse_path

Constructor Details

#initialize(config) ⇒ OAuth

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)



15
16
17
18
19
20
21
22
23
24
# 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 code_verifier])
  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

Instance Attribute Details

#access_tokenObject (readonly)

Returns the value of attribute access_token.



6
7
8
# File 'lib/zoom/clients/oauth.rb', line 6

def access_token
  @access_token
end

#expires_atObject (readonly)

Returns the value of attribute expires_at.



6
7
8
# File 'lib/zoom/clients/oauth.rb', line 6

def expires_at
  @expires_at
end

#expires_inObject (readonly)

Returns the value of attribute expires_in.



6
7
8
# File 'lib/zoom/clients/oauth.rb', line 6

def expires_in
  @expires_in
end

#refresh_tokenObject (readonly)

Returns the value of attribute refresh_token.



6
7
8
# File 'lib/zoom/clients/oauth.rb', line 6

def refresh_token
  @refresh_token
end

Instance Method Details

#authObject



26
27
28
# File 'lib/zoom/clients/oauth.rb', line 26

def auth
  refresh_token ? refresh : oauth
end

#oauthObject



36
37
38
39
40
41
42
43
44
45
46
# File 'lib/zoom/clients/oauth.rb', line 36

def oauth
  response = access_tokens(
    grant_type: 'authorization_code',
    auth_code: @auth_code,
    redirect_uri: @redirect_uri,
    code_verifier: @code_verifier
  )

  set_tokens(response)
  response
end

#refreshObject



30
31
32
33
34
# File 'lib/zoom/clients/oauth.rb', line 30

def refresh
  response = refresh_tokens(grant_type: 'refresh_token', refresh_token: @refresh_token)
  set_tokens(response)
  response
end

#revokeObject



48
49
50
51
52
# File 'lib/zoom/clients/oauth.rb', line 48

def revoke
  response = revoke_tokens(access_token: @access_token)
  set_tokens(response)
  response
end