Class: Twilio::REST::ClientCredentialProvider

Inherits:
CredentialProvider show all
Defined in:
lib/twilio-ruby/credential/client_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) ⇒ ClientCredentialProvider

Returns a new instance of ClientCredentialProvider.

Raises:

  • (ArgumentError)


10
11
12
13
14
15
16
17
18
19
# File 'lib/twilio-ruby/credential/client_credential_provider.rb', line 10

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.



8
9
10
# File 'lib/twilio-ruby/credential/client_credential_provider.rb', line 8

def auth_strategy
  @auth_strategy
end

#client_idObject

Returns the value of attribute client_id.



8
9
10
# File 'lib/twilio-ruby/credential/client_credential_provider.rb', line 8

def client_id
  @client_id
end

#client_secretObject

Returns the value of attribute client_secret.



8
9
10
# File 'lib/twilio-ruby/credential/client_credential_provider.rb', line 8

def client_secret
  @client_secret
end

#grant_typeObject

Returns the value of attribute grant_type.



8
9
10
# File 'lib/twilio-ruby/credential/client_credential_provider.rb', line 8

def grant_type
  @grant_type
end

#orgs_tokenObject

Returns the value of attribute orgs_token.



8
9
10
# File 'lib/twilio-ruby/credential/client_credential_provider.rb', line 8

def orgs_token
  @orgs_token
end

Instance Method Details

#to_auth_strategyObject



21
22
23
24
25
# File 'lib/twilio-ruby/credential/client_credential_provider.rb', line 21

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