Bry*_*iff 5 ruby-on-rails-3 google-api-client
我收到了google-api-ruby-client的以下错误:
NameError: uninitialized constant Google::APIClient::PKCS12
NameError: uninitialized constant Google::APIClient::JWTAsserter
Run Code Online (Sandbox Code Playgroud)
这是我的代码的概要:
require 'google/api_client'
class Commissions::GoogleAffiliateNetwork < ActiveRecord::Base
def self.path_to_key_file
Rails.root + 'config/xxx-privatekey.p12'
end
def self.passphrase
'supersecretphrase'
end
def self.service_email
'42@developer.gserviceaccount.com'
end
def api_auth_uri
'https://www.googleapis.com/auth/gan'
end
def self.make_request(opts = {})
key = Google::APIClient::PKCS12.load_key(path_to_key_file, passphrase)
asserter = Google::APIClient::JWTAsserter.new(service_email, api_auth_uri, key)
api_client = Google::APIClient.new
api_client.authorization = asserter.authorize()
end
end
Run Code Online (Sandbox Code Playgroud)
在Gemfile中:
gem 'google-api-client'
Run Code Online (Sandbox Code Playgroud)
我错过了什么吗?