Phy*_*ida 1 javascript google-drive-api
我想知道是否可以在随机计算机上打开一个jsfiddle并登录并验证并使用驱动器API,而无需一直运行本地服务器?一个人如何设置它?我很抱歉,如果这是一个简单的问题,但我只是因为我到目前为止发现的说明不清楚而丢失了.
编辑:
我也做了一个python应用程序,使用pydrive I:
但是,除此之外,我有点不确定,特别是:
我知道我很可能需要在开发人员控制台中设置公共API访问权限,但我不完全确定我应该使用哪些Referers.那么有一种简单的方法可以做到这一点吗?
我也知道gspread只能使用客户端的用户名和密码打开google excell电子表格,所以我怀疑我正在寻找的是可能的,但我不确定.
好的,所以我找到了一个效果很好的解决方案:
{
"access_token": "ya29.AwH-1N_gnstLBuZfOR4W9CCcggKrQpMyKYV4QVEtCiIzHozNU5AfUJoYQzukALfjdiw2iOCUve7JbQ",
"token_type": "Bearer",
"expires_in": 3600,
"provider": "google_drive"
}
要使用它,您可以执行以下操作:
// This only works because we're set to "No wrap - in <head>"
function ShowDriveFileList() {
var accessToken;
// Initialize OAuth with our key
OAuth.initialize('lmGlb8BaftfF4Y5en_c8XYOSq2A');
// Connect to google drive, and print out file list
OAuth.popup('google_drive').done(function (result) {
var xmlHttp = null;
xmlHttp = new XMLHttpRequest();
xmlHttp.open("GET", "https://www.googleapis.com/drive/v2/files", false);
xmlHttp.setRequestHeader("Authorization", "Bearer " + result.access_token);
xmlHttp.send(null);
alert(xmlHttp.responseText);
}).fail(function (err) {
alert(err);
});;
}
Run Code Online (Sandbox Code Playgroud)
您可以在http://jsfiddle.net/JMTVz/41/找到.这使用我的oauth.io客户端ID,但你可以用你的替换它,它也应该工作.