Class: Google::APIClient::Storage Deprecated
- Inherits:
 - 
      Object
      
        
- Object
 - Google::APIClient::Storage
 
 
- Defined in:
 - lib/google/api_client/auth/storage.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
Constant Summary collapse
- AUTHORIZATION_URI =
 'https://accounts.google.com/o/oauth2/auth'- TOKEN_CREDENTIAL_URI =
 'https://accounts.google.com/o/oauth2/token'
Instance Attribute Summary collapse
- #authorization ⇒ Signet::OAuth2::Client readonly
 - 
  
    
      #store  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
Storage object.
 
Instance Method Summary collapse
- 
  
    
      #authorize  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Loads credentials and authorizes an client.
 - 
  
    
      #initialize(store)  ⇒ Storage 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
Initializes the Storage object.
 - 
  
    
      #refresh_authorization  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
refresh credentials and save them to store.
 - 
  
    
      #write_credentials(authorization = nil)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Write the credentials to the specified store.
 
Constructor Details
#initialize(store) ⇒ Storage
Initializes the Storage object.
      41 42 43 44  | 
    
      # File 'lib/google/api_client/auth/storage.rb', line 41 def initialize(store) @store= store @authorization = nil end  | 
  
Instance Attribute Details
#authorization ⇒ Signet::OAuth2::Client (readonly)
      34 35 36  | 
    
      # File 'lib/google/api_client/auth/storage.rb', line 34 def @authorization end  | 
  
#store ⇒ Object
Returns Storage object.
      31 32 33  | 
    
      # File 'lib/google/api_client/auth/storage.rb', line 31 def store @store end  | 
  
Instance Method Details
#authorize ⇒ Object
Loads credentials and authorizes an client.
      62 63 64 65 66 67 68 69 70 71  | 
    
      # File 'lib/google/api_client/auth/storage.rb', line 62 def @authorization = nil cached_credentials = load_credentials if cached_credentials && cached_credentials.size > 0 @authorization = Signet::OAuth2::Client.new(cached_credentials) @authorization.issued_at = Time.at(cached_credentials['issued_at'].to_i) self. if @authorization.expired? end return @authorization end  | 
  
#refresh_authorization ⇒ Object
refresh credentials and save them to store
      75 76 77 78  | 
    
      # File 'lib/google/api_client/auth/storage.rb', line 75 def .refresh! self.write_credentials end  | 
  
#write_credentials(authorization = nil) ⇒ Object
Write the credentials to the specified store.
      52 53 54 55 56 57  | 
    
      # File 'lib/google/api_client/auth/storage.rb', line 52 def write_credentials(=nil) @authorization = if if @authorization.respond_to?(:refresh_token) && @authorization.refresh_token store.write_credentials(credentials_hash) end end  |