现在,随着google_drive gem的谷歌登录功能被弃用,我想知道如何访问电子表格?
我试着遵循下面的指南,但获取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谢谢,
发布于 2016-01-25 23:44:50
授权码的事情只会出现一次(第一次尝试访问文档时)
当我尝试这样做时,我通过控制台进行了尝试,得到的响应如下:
Google::APIClient -使用选项{:application_name=>"google_drive Ruby library",: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: )
就是这样。
在我的应用程序目录中创建了一个新文件,其中包含凭据、刷新令牌和所有内容。
https://stackoverflow.com/questions/34782828
复制相似问题