Parent

Class/Module Index [+]

Quicksearch

Google::APIClient::Storage

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

Attributes

authorization[R]

@return [Signet::OAuth2::Client]

store[RW]

@return [Object] Storage object.

Public Class Methods

new(store) click to toggle source

Initializes the Storage object.

@params [Object] Storage object

# File lib/google/api_client/auth/storage.rb, line 39
def initialize(store)
  @store= store
end

Public Instance Methods

authorize() click to toggle source

Loads credentials and authorizes an client. @return [Object] Signet::OAuth2::Client or NIL

# File lib/google/api_client/auth/storage.rb, line 59
def authorize
  @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.refresh_authorization if @authorization.expired?
  end
  return @authorization
end
refresh_authorization() click to toggle source

refresh credentials and save them to store

# File lib/google/api_client/auth/storage.rb, line 72
def refresh_authorization
  authorization.refresh!
  self.write_credentials
end
write_credentials(authorization=nil) click to toggle source

Write the credentials to the specified store.

@params [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/storage.rb, line 49
def write_credentials(authorization=nil)
  @authorization = authorization if authorization
  if @authorization.respond_to?(:refresh_token) && @authorization.refresh_token
    store.write_credentials(credentials_hash)
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.