ruby-on-rails - 无法加载此类文件 -- google/apis/compute_v1,使用服务帐户创建(服务器到服务器)Google 日历事件。使用 rails

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

我正在运行一个 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/

相关文章:

ruby-on-rails - 制作一个使用其关联范围的范围

ruby-on-rails - 如何在 pry 动时引用名为 frame 的变量

c# - "The underlying connection was closed: An unexpected error occurred on a send."WebClient.OpenRead 错误(字符串链接)

c# - 谷歌云 API 语法

ruby - 在 OS X Lion 上使用 RVM 安装 Ruby 1.9.2 失败

authentication - 尝试通过服务帐户发送电子邮件获取 com.google.api.client.auth.oauth2.TokenResponseException : 401 Unauthorized

jquery - 所见即所得的 jquery 编辑器分成两个文本区域

ruby-on-rails - rails : How is `translate` exposed to ActionController?

ruby-on-rails - kEND和$ end有什么区别?

ruby-on-rails - "ruby script/plugin"是命令吗?