Sha256: 7c81a4f6cc48e60ec4e7aac4b1afade7f3463d2687f52165eb784d9ed5a8140c

Contents?: true

Size: 1.02 KB

Versions: 4

Compression:

Stored size: 1.02 KB

Contents

# frozen_string_literal: true

require_relative 'credential_provider'
require_relative 'auth_type'
require_relative './../http/org_token_manager'
require_relative './../auth_strategy/token_auth_strategy'
module Twilio
  module REST
    class OrgsCredentialProvider < CredentialProvider
      attr_accessor :grant_type, :client_id, :client_secret, :orgs_token, :auth_strategy

      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

      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
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
twilio-ruby-7.4.3 lib/twilio-ruby/credential/orgs_credential_provider.rb
twilio-ruby-7.4.2 lib/twilio-ruby/credential/orgs_credential_provider.rb
twilio-ruby-7.4.1 lib/twilio-ruby/credential/orgs_credential_provider.rb
twilio-ruby-7.4.0 lib/twilio-ruby/credential/orgs_credential_provider.rb