class GcDatastore::Client

Constants

SCOPE

Public Class Methods

new(options) click to toggle source
# File lib/gc_datastore/client.rb, line 6
def initialize(options)
  @client = Google::APIClient.new(
    :application_name => options[:app_name],
    :application_version => options[:version])
end

Public Instance Methods

authorize(options) click to toggle source
# File lib/gc_datastore/client.rb, line 12
def authorize(options)
  private_key = Google::APIClient::KeyUtils.load_from_pkcs12(options[:key_path], 'noasecret')
  @client.authorization = Signet::OAuth2::Client.new(
    :token_credential_uri => 'https://accounts.google.com/o/oauth2/token',
    :audience => 'https://accounts.google.com/o/oauth2/token',
    :scope => SCOPE,
    :issuer => options[:account],
    :signing_key => private_key)
  @client.authorization.fetch_access_token!
end