Ruby on rails 3 google api ruby客户端找不到类PKCS12&;JWTAsserter
我在google api ruby客户端收到以下错误:Ruby on rails 3 google api ruby客户端找不到类PKCS12&;JWTAsserter,ruby-on-rails-3,google-api-client,Ruby On Rails 3,Google Api Client,我在google api ruby客户端收到以下错误: NameError: uninitialized constant Google::APIClient::PKCS12 NameError: uninitialized constant Google::APIClient::JWTAsserter 以下是我的代码摘要: require 'google/api_client' class Commissions::GoogleAffiliateNetwork < ActiveRe
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
我遗漏了什么吗?您使用的是哪个版本的gem?你能检查一下你是否在0.4.4上吗?是的,这就是问题所在-出于某种原因安装了0.3.0。升级到0.4.4后,问题就解决了!非常感谢。@Stevebazil必须把这些作为答案,伙计。:-)
gem 'google-api-client'