我收到以下关于 google-api-ruby-client 的错误:
NameError: uninitialized constant Google::APIClient::PKCS12
NameError: uninitialized constant Google::APIClient::JWTAsserter
这是我的代码的概要:
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
在 Gemfile 中:
gem 'google-api-client'
我错过了什么吗?