如何获取Google Drive API中修订版的exportLinks [英] How do I get exportLinks for revisions in Google Drive API

查看:137
本文介绍了如何获取Google Drive API中修订版的exportLinks的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Google Apps脚本尝试获取Google图形的各种修订版的exportLinks列表。下面的代码重现了这个问题。

  // Google oAuth 
函数googleOAuth_(名称)使用图形ID调用getRevisionHx。 ,范围){
var oAuthConfig = UrlFetchApp.addOAuthService(name);
oAuthConfig.setRequestTokenUrl(https://www.google.com/accounts/OAuthGetRequestToken?scope=+范围);
oAuthConfig.setAuthorizationUrl(https://www.google.com/accounts/OAuthAuthorizeToken);
oAuthConfig.setAccessTokenUrl(https://www.google.com/accounts/OAuthGetAccessToken);
oAuthConfig.setConsumerKey(anonymous);
oAuthConfig.setConsumerSecret(anonymous);
return {oAuthServiceName:name,oAuthUseToken:always};
}

函数getRevisionHx(resource_id){
var scope ='https://www.googleapis.com/auth/drive';
var myKey = KEY_DELETED_FROM_SAMPLE_CODE;

var fetchArgs = googleOAuth _('drive',scope);
fetchArgs.method ='GET';

var url =https://www.googleapis.com/drive/v2/files/+ resource_id +/ revisions?key =+ myKey;
var urlFetch = UrlFetchApp.fetch(url,fetchArgs);

... // snip

}

在snip中,urlFetch已经成功,并且它包含每个版本的exportLinks修订列表。如果我抓取其中一个exportLink并使用Web浏览器下载它,它始终检索文档的最新版本,而不是指定的修订版本。这是一个错误还是我做错了什么?



换句话说,上述所有代码似乎都正常工作(API调用成功并返回所期望的) ,但返回的exportLink URL并不指向它们表示他们愿意修改的版本。 解决方案

同样的结果已被转载。 / p>

我会为您报告。抱歉给您带来不便。


I am using Google Apps Scripts to attempt to get a list of exportLinks for the various revisions of a Google Drawing. The code below reproduces the problem. To try it out, call getRevisionHx with the ID of a drawing.

//Google oAuth
function googleOAuth_(name,scope) {
  var oAuthConfig = UrlFetchApp.addOAuthService(name);
  oAuthConfig.setRequestTokenUrl("https://www.google.com/accounts/OAuthGetRequestToken?scope="+scope);
      oAuthConfig.setAuthorizationUrl("https://www.google.com/accounts/OAuthAuthorizeToken");
  oAuthConfig.setAccessTokenUrl("https://www.google.com/accounts/OAuthGetAccessToken");
  oAuthConfig.setConsumerKey("anonymous");
  oAuthConfig.setConsumerSecret("anonymous");
  return {oAuthServiceName:name, oAuthUseToken:"always"};
}

function getRevisionHx(resource_id){
  var scope = 'https://www.googleapis.com/auth/drive';
  var myKey = KEY_DELETED_FROM_SAMPLE_CODE;

  var fetchArgs = googleOAuth_('drive', scope);
  fetchArgs.method = 'GET';

  var url = "https://www.googleapis.com/drive/v2/files/" + resource_id + "/revisions?key=" + myKey;
  var urlFetch = UrlFetchApp.fetch(url, fetchArgs);

... //snip

}

At the snip, the urlFetch has succeeded and it has a list of revisions with exportLinks for each of them. If I grab one of those exportLinks and download it using a web browser, it always retrieves the latest version of the document, not the specified revision. Is this a bug or am I doing something wrong?

In other words, all of the above code seems to work fine (the API call succeeds and returns what is expected), but the exportLink URLs returned don't point to the revision they say they will.

解决方案

Same result has been reproduced.

I will report this for you. Sorry for inconvenience.

这篇关于如何获取Google Drive API中修订版的exportLinks的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆