我正在运行一个 Rails 应用程序,并试图在客户提出送货请求时为我们创建 Google 日历事件。我已经创建了服务帐户并正在尝试获取我的 oauth working我的 Controller 与他们建议的基本相同。要求 googleauth 正在工作,因为我有 google api gem 但它找不到 google/apis/compute_v1 并且不会超过它。我找不到它应该来自哪里的描述。有人知道吗?
class CalendarController < ApplicationController
require 'googleauth'
require 'google/apis/compute_v1'
def create_event
compute = Google::Apis::ComputeV1::ComputeService.new
# Get the environment configured authorization
scopes = ['https://www.googleapis.com/auth/cloud-platform', 'https://www.googleapis.com/auth/compute', 'https://www.googleapis.com/auth/calendar']
compute.authorization = Google::Auth.get_application_default(scopes)
end
end
这是我在尝试激活 calendar#create_event 时遇到的错误
无法加载这样的文件 -- google/apis/compute_v1
Extracted source (around line #3):
class CalendarController < ApplicationController
require 'googleauth'
require 'google/apis/compute_v1'
def create_event
compute = Google::Apis::ComputeV1::ComputeService.new
Rails.root: /Users/myname/Code/foldername/appname
应用程序跟踪 |框架跟踪 |全迹
应用程序/ Controller /calendar_controller.rb:3:in <class:CalendarController>'
app/controllers/calendar_controller.rb:1:in
'
加载以下文件时发生此错误:
谷歌/apis/compute_v1
最佳答案
原来我需要把它放在我的 gem 文件中 gem 'google-api-client', '0.9.pre1' 我有 gem 'google-api-client',它使用的是该 gem 的早期版本。
关于ruby-on-rails - 无法加载此类文件 -- google/apis/compute_v1,使用服务帐户创建(服务器到服务器)Google 日历事件。使用 rails ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31397345/