google-api-ruby-client/lib
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
..
compat Merge pull request #13 from sanemat/multi-json-in-rails-case 2012-12-30 11:20:01 -08:00
google Added Google::APIClient::FileStorage, to save OAuth 2 credentials to disk 2013-05-29 15:31:44 -04:00