I'm writting a script in Google Aps (GAS) and I need to add a user(/writer) (administrator of the domain) to a spreadsheed of a another user.
The script is running/invoked under administrator privilegies.
First I use "Google Apps administrative access to impersonate a user of the domain" and I get a list of his documents (spreadsheets) and I get the Id of the documents.
var oauthConfig = UrlFetchApp.addOAuthService("docs"); oauthConfig.setAccessTokenUrl("https://www.google.com/accounts/OAuthGetAccessToken"); oauthConfig.setRequestTokenUrl("https://www.google.com/accounts/OAuthGetRequestToken? (...)
This part is working fine and get the desired Id's.
Now, I want to add to myself ([email protected]) to this document
I'm trying this:
var optAdvancedArgs = {
"contentType": "application/atom+xml",
"method": "POST",
"headers": { "GData-Version": "3.0" },
"oAuthServiceName": "docs",
"oAuthUseToken": "always",
};
var url_set = "https://docs.google.com/feeds/" + user + "/private/full/document:" + matriu2[0][6] + '/acl/user:[email protected]'
var result = UrlFetchApp.fetch(url_set, optAdvancedArgs);
"user" is the owner of the document, the active user (Session.getActiveUser().getUserLoginId()) and "matriu2[nm][6]" is the Id of the document.
This don't work,
Any ideas ?
Sergi