Class: Google::APIClient::FileStore Deprecated
- Inherits:
-
Object
- Object
- Google::APIClient::FileStore
- 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
-
#path ⇒ Object
Returns the value of attribute path.
Instance Method Summary collapse
-
#initialize(path) ⇒ FileStore
constructor
Initializes the FileStorage object.
-
#load_credentials ⇒ Object
Attempt to read in credentials from the specified file.
-
#write_credentials(credentials_hash) ⇒ Object
Write the credentials to the specified file.
Constructor Details
#initialize(path) ⇒ FileStore
Initializes the FileStorage object.
34 35 36 |
# File 'lib/google/api_client/auth/storages/file_store.rb', line 34 def initialize(path) @path= path end |
Instance Attribute Details
#path ⇒ Object
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_credentials ⇒ Object
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.
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 |