「プロパティを設定できません」に関する投稿がいくつかありますが、ここで何が欠けているかを特定するのにまだ苦労しています。私はJavascriptとGASが初めてです。私は「GScript エンタープライズ アプリケーションの要点」という GAS に関する本を書いています。このコードは本からのもので、うまく機能していません。それはそれを2回実行することを示しており、ある時点で承認を求めるプロンプトが表示されましたが、これは1回だけ発生し、それ以前とそれ以降にこのエラーが発生しました。誰かがそれを理解するのを助けるために私が相談できるリソースまたは何かを提案できますか..またはおそらくエラーをよりよく理解できますか?? ありがとう!!
コード
/*
* Private for OAuth
* @ returns OAuth headers
*/
DOCS_LIST_API.googleOAuth = function() {
var oAuthConfig = UrlFetchApp.addOAuthService("google");
oAuthConfig.setRequestTokenUrl("https://www.google.com/accounts/OAuthGetRequestToken? scope=https://docs.google.com/feeds/");
oAuthConfig.setAuthorizationUrl("https://www.google.com/accounts/OAuthAuthorizeToken");
oAuthConfig.setAccessTokenUrl("https://www.google.com/accounts/OAuthGetAccessToken");
oAuthConfig.setConsumerKey('anonymous');
oAuthConfig.setConsumerSecret('anonymous');
return {oAuthServiceName:'google', oAuthUseToken:"always"};
}
var DOCS_LIST_API = {};
/*
* @ args docID String the id for a Google Document
* @ args format String can be, "txt", "odt", "pdf", "html", "rtf", "doc", "png",
"zip"
* @ returns blob
*
*/
DOCS_LIST_API.GdocToFormat = function(docID, format){
var fetchArgs = DOCS_LIST_API.googleOAuth;
fetchArgs.headers = { "GData-Version": "3.0" };
fetchArgs.method = 'get';
var url = 'https://docs.google.com/feeds/download/documents/export/Export?id='+
docID+'&exportFormat='+format+'&format='+format;
return UrlFetchApp.fetch(url, fetchArgs);
}
// Run it twice
function doOAuth(){
try{
DOCS_LIST_API.GdocToFormat();
}catch(e){
}
}