Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ruby-on-rails-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/reporting-services/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 3 如何使用omniauth+从Rails 3应用程序访问Google Drive;omniauth谷歌应用程序_Ruby On Rails 3_Omniauth_Google Drive Api - Fatal编程技术网

Ruby on rails 3 如何使用omniauth+从Rails 3应用程序访问Google Drive;omniauth谷歌应用程序

Ruby on rails 3 如何使用omniauth+从Rails 3应用程序访问Google Drive;omniauth谷歌应用程序,ruby-on-rails-3,omniauth,google-drive-api,Ruby On Rails 3,Omniauth,Google Drive Api,我正在尝试使用gem访问googledrive,但没有成功。该gem有一个使用auth登录的选项,但我不知道如何从omniauth获取访问令牌。返回的架构为 这是我的密码 在models/user.rb中 def self.create_with_omniauth(auth, role = 'user') create! do |user| user.email = auth['info']['email'] user.first_name = auth['info']['f

我正在尝试使用gem访问googledrive,但没有成功。该gem有一个使用auth登录的选项,但我不知道如何从omniauth获取访问令牌。返回的架构为

这是我的密码

在models/user.rb中

def self.create_with_omniauth(auth, role = 'user')
  create! do |user|
    user.email = auth['info']['email']
    user.first_name = auth['info']['first_name']
    user.last_name = auth['info']['last_name']
    user.google_token = auth['credential']['token']
    user.google_secret = auth['credential']['secret']
    user.role = Role.where(:account_type => role).first_or_create
  end
end
在控制器/会话中\u coontroller.rb

auth = request.env["omniauth.auth"]
email = auth['info']['email']
user = User.find_by_email(email) || User.create_with_omniauth(auth)
def index
  session = GoogleDrive.login_with_oauth(current_user.google_tocken)
  for file in session.files
    @docs << file
  end
end
和在控制器/文档\u controller.rb中

auth = request.env["omniauth.auth"]
email = auth['info']['email']
user = User.find_by_email(email) || User.create_with_omniauth(auth)
def index
  session = GoogleDrive.login_with_oauth(current_user.google_tocken)
  for file in session.files
    @docs << file
  end
end
def索引
session=GoogleDrive.login\u with\u oauth(当前用户.google\u tocken)
对于session.files中的文件
@文件