Class: GoogleSpreadsheets::Auth::ServiceAccountsAccessToken

Inherits:
Object
  • Object
show all
Defined in:
lib/google_spreadsheets/auth/service_accounts_access_token.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ ServiceAccountsAccessToken

Returns a new instance of ServiceAccountsAccessToken.



6
7
8
9
# File 'lib/google_spreadsheets/auth/service_accounts_access_token.rb', line 6

def initialize(options = {})
  @options = options
  @options[:scope] ||= 'https://spreadsheets.google.com/feeds/'
end

Instance Method Details

#call(connection) ⇒ Object



11
12
13
14
15
# File 'lib/google_spreadsheets/auth/service_accounts_access_token.rb', line 11

def call(connection)
  @authorizer ||= Google::Auth::ServiceAccountCredentials.make_creds(@options)
  @authorizer.refresh! if @authorizer.expires_at.nil? || @authorizer.expired?
  @authorizer.access_token
end