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
Initializes the FileStorage object.
@param [String] path
Path to the credentials file.
# File lib/google/api_client/auth/storages/file_store.rb, line 33 def initialize(path) @path= path end
Attempt to read in credentials from the specified file.
# File lib/google/api_client/auth/storages/file_store.rb, line 39 def load_credentials open(path, 'r') { |f| JSON.parse(f.read) } rescue nil end
Write the credentials to the specified file.
@param [Signet::OAuth2::Client] authorization
Optional authorization instance. If not provided, the authorization already associated with this instance will be written.
# File lib/google/api_client/auth/storages/file_store.rb, line 51 def write_credentials(credentials_hash) open(self.path, 'w+') do |f| f.write(credentials_hash.to_json) end end