class Google::APIClient::FileStore

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

@deprecated Use google-auth-library-ruby instead

Attributes

path[RW]

Public Class Methods

new(path) click to toggle source

Initializes the FileStorage object.

@param [String] path

Path to the credentials file.
# File lib/google/api_client/auth/storages/file_store.rb, line 34
def initialize(path)
  @path= path
end

Public Instance Methods

load_credentials() click to toggle source

Attempt to read in credentials from the specified file.

# 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) click to toggle source

Write the credentials to the specified file.

@param [Hash] credentials_hash

# 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