Sha256: 94b45d4330803a3312201911f8524f9035dfbbf8562b3e3ce0c64b3c511e6e30

Contents?: true

Size: 965 Bytes

Versions: 4

Compression:

Stored size: 965 Bytes

Contents

module GoogleSpreadsheetFetcher
  module Authorizer
    module Oauth2
      class Config
        attr_reader :client_secrets_json_path, :user_id, :token_store, :client_id

        def initialize(client_secrets_json_path: nil, user_id: nil, token_store: nil)
          @client_secrets_json_path = client_secrets_json_path || ::GoogleSpreadsheetFetcher.config.client_secrets_file
          @user_id = user_id || ::GoogleSpreadsheetFetcher.config.user_id
          @token_store = token_store || default_token_store
          @client_id = ::Google::Auth::ClientId.from_file(self.client_secrets_json_path)

          freeze
        end

        private

        def default_token_store
          store = ::GoogleSpreadsheetFetcher.config.token_store
          return store if store.present?

          file = ::GoogleSpreadsheetFetcher.config.credential_store_file
          ::Google::Auth::Stores::FileTokenStore.new(file: file)
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
google_spreadsheet_fetcher-2.2.0 lib/google_spreadsheet_fetcher/authorizer/oauth2/config.rb
google_spreadsheet_fetcher-2.1.0 lib/google_spreadsheet_fetcher/authorizer/oauth2/config.rb
google_spreadsheet_fetcher-2.0.1 lib/google_spreadsheet_fetcher/authorizer/oauth2/config.rb
google_spreadsheet_fetcher-2.0.0 lib/google_spreadsheet_fetcher/authorizer/oauth2/config.rb