【问题标题】:cannot load such file -- google/apis/compute_v1, Using service accounts to create (server to server) Google Calendar events. Using rails无法加载此类文件 - google/apis/compute_v1,使用服务帐户创建(服务器到服务器)Google 日历事件。使用导轨
【发布时间】:2015-07-14 03:53:38
【问题描述】:

我正在运行一个 Rails 应用程序,并尝试在客户提出交付请求时为我们创建谷歌日历事件。我已经创建了服务帐户并试图让我的oauth working 我的控制器与他们建议的基本相同。要求 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

应用程序跟踪 |框架跟踪 |全跟踪 应用程序/控制器/calendar_controller.rb:3:in <class:CalendarController>' app/controllers/calendar_controller.rb:1:in' 加载以下文件时发生此错误: google/apis/compute_v1

【问题讨论】:

  • 请分享错误信息/日志。
  • Justs 共享错误内容

标签: ruby-on-rails ruby google-api google-calendar-api service-accounts


【解决方案1】:

原来我需要把它放在我的 gem 文件 gem 'google-api-client', '0.9.pre1' 我有 gem 'google-api-client',它使用的是早期版本的 gem。

【讨论】:

    猜你喜欢
    • 2021-10-31
    • 2012-08-05
    • 2021-08-12
    • 1970-01-01
    • 2021-03-29
    • 1970-01-01
    • 2020-08-27
    • 2021-09-30
    • 1970-01-01
    相关资源
    最近更新 更多