Class: Google::APIClient::FileStore Deprecated

Inherits:
Object
  • Object
show all
Defined in:
lib/google/api_client/auth/storages/file_store.rb

Overview

Deprecated.

Use google-auth-library-ruby instead

Represents cached OAuth 2 tokens stored on local disk in a JSON serialized file. Meant to resemble the serialized format http://google-api-python-client.googlecode.com/hg/docs/epy/oauth2client.file.Storage-class.html

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ FileStore

Initializes the FileStorage object.

Parameters:

  • path (String)

    Path to the credentials file.



34
35
36
# File 'lib/google/api_client/auth/storages/file_store.rb', line 34

def initialize(path)
  @path= path
end

Instance Attribute Details

#pathObject

Returns the value of attribute path



27
28
29
# File 'lib/google/api_client/auth/storages/file_store.rb', line 27

def path
  @path
end

Instance Method Details

#load_credentialsObject

Attempt to read in credentials from the specified file.



40
41
42
43
44
# File 'lib/google/api_client/auth/storages/file_store.rb', line 40

def load_credentials
  open(path, 'r') { |f| JSON.parse(f.read) }
rescue
  nil
end

#write_credentials(credentials_hash) ⇒ Object

Write the credentials to the specified file.

Parameters:

  • credentials_hash (Hash)


50
51
52
53
54
# File 'lib/google/api_client/auth/storages/file_store.rb', line 50

def write_credentials(credentials_hash)
  open(self.path, 'w+') do |f|
    f.write(credentials_hash.to_json)
  end
end