2012-10-19 99 views
1

刪除共享許可使用URLFetchApp文檔ACL用戶...谷歌應用程序腳本,刪除文檔共享權限

下面是我的代碼

function removeSharing(docId,userToRemove) 
    { 
     var base = 'https://docs.google.com/feeds/default/'; 
     var fetchArgs = googleOAuthDeleteUser_('docs', base); 
     var url = base+'private/full/'+docId+'/acl/'+encodeURIComponent(userToRemove); 
     var content = UrlFetchApp.fetch(url, fetchArgs).getContentText(); 
     return 'ok'; 
    } 
    function googleOAuthDeleteUser_(name,scope) { 
     var oAuthConfig = UrlFetchApp.addOAuthService(name); 
     oAuthConfig.setRequestTokenUrl("https://www.google.com/accounts/OAuthGetRequestToken?scope="+encodeURIComponent(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", 
       headers : { 
          "GData-Version": "3.0", 
          "If-Match":"*" 
       }, 
       method : "DELETE", 
       contentType : 'application/x-www-form-urlencoded' 
     }; 
    } 

它給我錯誤

請求失敗,返回代碼400.服務器響應:GData InvalidEntryException 發佈條目缺少一個或多個必填字段: scop e

請幫忙整理一下。

回答

1

the API docs,你的參數應該是這樣的:

DELETE https://docs.google.com/feeds/default/private/full/resource_id/acl/user:[email protected] 

如果userToRemove只有一個電子郵件地址,那麼這可能是失蹤的範圍。