Commit Graph

8 Commits

Author SHA1 Message Date
Michael C. Beck 0e9637c77c rename file_store 2013-11-15 10:26:18 +01:00
Volker Zöpfel c2135d9dcf split storages in own adapter classes, added redis adapter 2013-11-14 15:50:06 +01:00
Volker Zöpfel bd7cf179f3 adds Constants for Authorization_uri, Token_credentials_uri
extracts authorize
extracts credentials_hash
2013-11-14 14:45:36 +01:00
Volker Zöpfel bbb24a5d2e using the path= method on initialize 2013-11-14 08:32:47 +01:00
Volker Zöpfel 10a337b807 adds method path= to proof if file can be accessed 2013-11-14 08:31:21 +01:00
Volker Zöpfel 146ccad83a using symbols as hash keys 2013-11-14 08:19:21 +01:00
Volker Zöpfel 5538bded1f refactoring load_credentials
adding refresh_authorization

write_credentials now using the authorizations methods not the instance variables, Using the instance variables can cause problems.
2013-11-14 08:17:08 +01:00
Jeff Posnick fb67a021e7 Added Google::APIClient::FileStorage, to save OAuth 2 credentials to disk
This is a (potentially rough) bit of code to persist OAuth 2
credentials to disk, similar to
http://google-api-python-client.googlecode.com/hg/docs/epy/oauth2client.
file.Storage-class.html

It can be used in the following manner, which roughly translates to
what the Python client library code looks like.

  file_storage = Google::APIClient::FileStorage.new("#{$0}-oauth2.json")
  if file_storage.authorization.nil?
    client_secrets = Google::APIClient::ClientSecrets.load
    flow = Google::APIClient::InstalledAppFlow.new(
      :client_id => client_secrets.client_id,
      :client_secret => client_secrets.client_secret,
      :scope => [SCOPE1, SCOPE2]
    )
    client.authorization = flow.authorize(file_storage)
  else
    client.authorization = file_storage.authorization
  end
2013-05-29 15:31:44 -04:00