[英]ruby gem 'google_drive' - No such file or directory - gcloud
[英]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.