繁体   English   中英

ruby google_drive gem如何访问谷歌驱动器

[英]ruby google_drive gem how to access google drive

现在,随着google_drive gem中已弃用的google-login功能的出现,我想知道如何访问电子表格?

我尝试遵循以下准则,但是获取client_secret的链接已断开。 我去了谷歌开发人员,给自己一个包含client_ID的json文件,但是现在我的简单代码输出了一个获取授权代码的链接,但是我不确定如何使用该授权代码。

http://www.rubydoc.info/gems/google_drive/1.0.5

有人可以帮助我使用此gem访问我的电子表格吗?

我基本上是尝试遵循文档中的示例。

require "google/api_client"
require "google_drive"

# Creates a session. This will prompt the credential via command line for the
# first time and save it to config.json file for later usages.
session = GoogleDrive.saved_session("config.json")

# First worksheet of
# https://docs.google.com/spreadsheet/ccc?key=pz7XtlQC-PYx-jrVMJErTcg
# Or https://docs.google.com/a/someone.com/spreadsheets/d/pz7XtlQC-PYx-jrVMJErTcg/edit?usp=drive_web
ws = session.spreadsheet_by_key("pz7XtlQC-PYx-jrVMJErTcg").worksheets[0]

# Gets content of A2 cell.
p ws[2, 1]  #==> "hoge"

# Changes content of cells.
# Changes are not sent to the server until you call ws.save().
ws[2, 1] = "foo"
ws[2, 2] = "bar"
ws.save

谢谢,

授权码只会出现一次(第一次尝试访问doc时)

当我尝试此操作时,我通过控制台对其进行了尝试,并且得到如下响应:

Google :: APIClient-使用选项{:application_name =>“ google_drive Ruby库”,:application_version =>“ 0.4.0”}初始化客户端

1. Open this page:
https://accounts.google.com/o/oauth2/auth?access_type=offline&client_id=***************************&redirect_uri=urn:ietf:wg:oauth:2.0:oob&response_type=code&scope=https://www.googleapis.com/auth/drive%20https://spreadsheets.google.com/feeds/

2. Enter the authorization code shown in the page: 

转到给定的URL,我得到了您提到的授权代码。 因此,我要做的就是按照上面的指示复制代码并将其粘贴( 2. Enter the authorization code shown in the page:

就是这样。

在我的应用程序目录中创建了一个新文件,其中包含凭据以及刷新令牌和所有内容。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM