Class: Twilio::REST::OrgTokenManager

Inherits:
Object
  • Object
show all
Defined in:
lib/twilio-ruby/http/org_token_manager.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(grant_type, client_id, client_secret, code = nil, redirect_uri = nil, audience = nil, refresh_token = nil, scope = nil) ⇒ OrgTokenManager

Returns a new instance of OrgTokenManager.

Raises:

  • (ArgumentError)


6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/twilio-ruby/http/org_token_manager.rb', line 6

def initialize(grant_type, client_id, client_secret, code = nil, redirect_uri = nil, audience = nil,
               refresh_token = nil, scope = nil)
  raise ArgumentError, 'client_id and client_secret are required' if client_id.nil? || client_secret.nil?

  @grant_type = grant_type
  @client_id = client_id
  @client_secret = client_secret
  @code = code
  @redirect_uri = redirect_uri
  @audience = audience
  @refresh_token = refresh_token
  @scope = scope
end

Instance Attribute Details

#audienceObject

Returns the value of attribute audience.



4
5
6
# File 'lib/twilio-ruby/http/org_token_manager.rb', line 4

def audience
  @audience
end

#client_idObject

Returns the value of attribute client_id.



4
5
6
# File 'lib/twilio-ruby/http/org_token_manager.rb', line 4

def client_id
  @client_id
end

#client_secretObject

Returns the value of attribute client_secret.



4
5
6
# File 'lib/twilio-ruby/http/org_token_manager.rb', line 4

def client_secret
  @client_secret
end

#codeObject

Returns the value of attribute code.



4
5
6
# File 'lib/twilio-ruby/http/org_token_manager.rb', line 4

def code
  @code
end

#grant_typeObject

Returns the value of attribute grant_type.



4
5
6
# File 'lib/twilio-ruby/http/org_token_manager.rb', line 4

def grant_type
  @grant_type
end

#redirect_uriObject

Returns the value of attribute redirect_uri.



4
5
6
# File 'lib/twilio-ruby/http/org_token_manager.rb', line 4

def redirect_uri
  @redirect_uri
end

#refresh_tokenObject

Returns the value of attribute refresh_token.



4
5
6
# File 'lib/twilio-ruby/http/org_token_manager.rb', line 4

def refresh_token
  @refresh_token
end

#scopeObject

Returns the value of attribute scope.



4
5
6
# File 'lib/twilio-ruby/http/org_token_manager.rb', line 4

def scope
  @scope
end

Instance Method Details

#fetch_access_tokenObject



20
21
22
23
24
25
# File 'lib/twilio-ruby/http/org_token_manager.rb', line 20

def fetch_access_token
  client = Twilio::REST::Client.new
  token_instance = client.preview_iam.v1.token.create(grant_type: @grant_type,
                                                      client_id: @client_id, client_secret: @client_secret)
  token_instance.access_token
end