module GoogleCells
Constants
- VERSION
Attributes
client[RW]
config[RW]
Public Class Methods
configure() { |config| ... }
click to toggle source
# File lib/google_cells.rb, line 24 def self.configure self.config ||= Configuration.new yield(config) self.client = Google::APIClient.new( :application_name => 'GoogleCells App', :application_version => '0.0.3' ) if config.path_to_credentials_file config_from_file elsif config.client_id config_web_application else config_service_account end client.authorization.scope = ['https://www.googleapis.com/auth/drive', 'https://spreadsheets.google.com/feeds'] client.authorization.token_credential_uri = 'https://accounts.google.com/o/oauth2/token' config end
Private Class Methods
config_from_file()
click to toggle source
# File lib/google_cells.rb, line 75 def self.config_from_file flow = Google::APIClient::FileStorage.new( :path => config.path_to_credentials_file ) client.authorization = flow.authorize end
config_service_account()
click to toggle source
# File lib/google_cells.rb, line 65 def self.config_service_account key = Google::APIClient::KeyUtils.load_from_pkcs12(config.key_file, config.key_secret) opts = { issuer: config.service_account_email, signing_key: key } client.authorization = Signet::OAuth2::Client.new(opts) client.authorization.audience = 'https://accounts.google.com/o/oauth2/token' end
config_web_application()
click to toggle source
# File lib/google_cells.rb, line 60 def self.config_web_application client.authorization.client_id = config.client_id client.authorization.client_secret = config.client_secret end