Google apps script 如何在google脚本中使用驱动API在文件夹中插入文件

Google apps script 如何在google脚本中使用驱动API在文件夹中插入文件,google-apps-script,google-drive-api,Google Apps Script,Google Drive Api,我有一个文件夹,我想在其中插入一个文件…文件是一个图像,其url是我在photoURL变量中提供的 我的代码: var consumerKey="yourDomain.com"; var consumerSecret="yourSecretKey"; function image() { // Photo url var photoURL="photourl" // Getting content of Image var

我有一个文件夹,我想在其中插入一个文件…文件是一个图像,其url是我在photoURL变量中提供的 我的代码:

var consumerKey="yourDomain.com";
var consumerSecret="yourSecretKey";
function image() {
         // Photo url
         var photoURL="photourl"

         // Getting content of Image
         var imageContent=UrlFetchApp.fetch(photoURL).getContent()      

         // Storing image into drive
       storeIntoDrive(imageContent)      
}



// Oauth Authentication
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(consumerKey);
  oAuthConfig.setConsumerSecret(consumerSecret);
  return {oAuthServiceName:name, oAuthUseToken:"always"};
}



//  To store image into Google Drive
function storeIntoDrive(content){
  var base="https://www.googleapis.com/auth/drive.file"
  var url='https://www.googleapis.com/upload/drive/v2/files?uploadType=media'
  var fetchArgs=googleOAuth_('drives',base)
  fetchArgs.payload=content
  fetchArgs.method='POSt'
  fetchArgs.contentType="images/jpeg"
  fetchArgs.header={"title" : "demo", "mimeType" : "image/jpeg",
  "parents": [{
    "kind": "drive#fileLink",
    "id": "0B3qF7GcD2uDHc2J5d21haFJFc0k"
  }]}
  var result=UrlFetchApp.fetch(url,fetchArgs)
}
它没有插入图像…我应该做什么更改

它给出了错误:


请求返回代码403失败。服务器响应:{“错误”:{“错误”:[{“域”:“usageLimits”,“原因”:“dailyLimitExceededUnreg”,“消息”:“超出未经验证使用的每日限制。继续使用需要注册。”,“extendedHelp”:“}],“代码”:403,“消息”:“超出未经验证使用的每日限制。继续使用需要注册。”}这是因为您的访问令牌问题,您必须为“”获取访问令牌


下载最新的google api控制台,然后按照文档进行尝试。

seing“继续使用需要注册”是否使用功能验证?正在查找描述如何指定父项的代码段。以上代码对我来说是可行的。:)