Class: GcDatastore::Client
- Inherits:
-
Object
- Object
- GcDatastore::Client
- Defined in:
- lib/gc_datastore/client.rb
Constant Summary collapse
- SCOPE =
['https://www.googleapis.com/auth/datastore', 'https://www.googleapis.com/auth/userinfo.email']
Instance Method Summary collapse
- #authorize(options) ⇒ Object
-
#initialize(options) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(options) ⇒ Client
Returns a new instance of Client.
6 7 8 9 10 |
# File 'lib/gc_datastore/client.rb', line 6 def initialize() @client = Google::APIClient.new( :application_name => [:app_name], :application_version => [:version]) end |
Instance Method Details
#authorize(options) ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/gc_datastore/client.rb', line 12 def () private_key = Google::APIClient::KeyUtils.load_from_pkcs12([:key_path], 'noasecret') @client. = 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 => [:account], :signing_key => private_key) @client..fetch_access_token! end |