Sha256: 89fc7be556ad8c8101c6f0529a3d98702a2dd9b138de69316515f915c2d02dee

Contents?: true

Size: 786 Bytes

Versions: 1

Compression:

Stored size: 786 Bytes

Contents

module BigBroda
  class Auth

    attr_accessor :api, :client
    cattr_accessor :api, :client

    def initialize
      @config = BigBroda::Config
      @key = Google::APIClient::KeyUtils.load_from_pkcs12(@config.key_file, @config.pass_phrase)
      @asserter = Google::APIClient::JWTAsserter.new( @config.email, @config.scope, @key)
    end

    def authorize
      @client = Google::APIClient.new(application_name: "BigBroda", application_version: BigBroda::VERSION )
      @client.authorization = @asserter.authorize
      @client.retries = @config.retries.to_i if @config.retries.to_i > 1
      @api = @client.discovered_api('bigquery', 'v2')
      self.class.api = @api
      self.class.client = @client
    end

    def self.authorized?
      client.present?
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bigbroda-0.1.0.pre lib/bigbroda/auth.rb