Class: Twilio::REST::OrgsCredentialProvider

Inherits:
CredentialProvider show all
Defined in:
lib/twilio-ruby/credential/orgs_credential_provider.rb

Instance Attribute Summary collapse

Attributes inherited from CredentialProvider

#auth_type

Instance Method Summary collapse

Constructor Details

#initialize(client_id, client_secret, orgs_token = nil) ⇒ OrgsCredentialProvider

Returns a new instance of OrgsCredentialProvider.

Raises:

  • (ArgumentError)


12
13
14
15
16
17
18
19
20
21
# File 'lib/twilio-ruby/credential/orgs_credential_provider.rb', line 12

def initialize(client_id, client_secret, orgs_token = nil)
  super(AuthType::ORGS_TOKEN)
  raise ArgumentError, 'client_id and client_secret are required' if client_id.nil? || client_secret.nil?

  @grant_type = 'client_credentials'
  @client_id = client_id
  @client_secret = client_secret
  @orgs_token = orgs_token
  @auth_strategy = nil
end

Instance Attribute Details

#auth_strategyObject

Returns the value of attribute auth_strategy.



10
11
12
# File 'lib/twilio-ruby/credential/orgs_credential_provider.rb', line 10

def auth_strategy
  @auth_strategy
end

#client_idObject

Returns the value of attribute client_id.



10
11
12
# File 'lib/twilio-ruby/credential/orgs_credential_provider.rb', line 10

def client_id
  @client_id
end

#client_secretObject

Returns the value of attribute client_secret.



10
11
12
# File 'lib/twilio-ruby/credential/orgs_credential_provider.rb', line 10

def client_secret
  @client_secret
end

#grant_typeObject

Returns the value of attribute grant_type.



10
11
12
# File 'lib/twilio-ruby/credential/orgs_credential_provider.rb', line 10

def grant_type
  @grant_type
end

#orgs_tokenObject

Returns the value of attribute orgs_token.



10
11
12
# File 'lib/twilio-ruby/credential/orgs_credential_provider.rb', line 10

def orgs_token
  @orgs_token
end

Instance Method Details

#to_auth_strategyObject



23
24
25
26
27
# File 'lib/twilio-ruby/credential/orgs_credential_provider.rb', line 23

def to_auth_strategy
  @orgs_token = OrgTokenManager.new(@grant_type, @client_id, @client_secret) if @orgs_token.nil?
  @auth_strategy = TokenAuthStrategy.new(@orgs_token) if @auth_strategy.nil?
  @auth_strategy
end