Google 캘린더에서 약속을 가져 와서 Google 시트로 복사하고 XLS로 변환 한 다음 이메일을 보내려면 Google Apps Script를 사용했습니다. 이번 주까지는 괜찮 았어.Google Apps 스크립트에서 XLS로 시트를 내보낼 때 OAuth 오류가 발생했습니다.
처음에는 새 버전의 스프레드 시트로 인해 302 오류가 발생했습니다. 여기에 설명되어 있습니다 : Export (or print) with a google script new version of google spreadsheets to pdf file, using pdf options
HTTP 예외를 음소거하고 그에 따라 URL을 조정하여 파일의 새 위치를 얻었습니다. 또한 제안 된대로 OAuth 범위를 https://docs.google.com/feeds/
으로 업데이트했습니다.
프로그램이 "OAuth 오류"메시지와 함께 실패합니다. muteHttpExceptions가 true로 설정되면 메시지는 "서비스 인증을받지 못했습니다 : google"입니다.
이것이 범위 문제라고 생각하지만 실제로 잘못한 것을 볼 수 없습니다. 당연히, 나는 운없이 다른 가능성을 시도했다.
아래 코드를 포함 시켰습니다. 주석 처리 된 코드는 이번 주까지 작업 한 수업입니다.
function getSSAsExcel(ssID)
{
var format = "xls";
//var scope = "https://spreadsheets.google.com/feeds/";
var scope = "https://docs.google.com/feeds/";
var oauthConfig = UrlFetchApp.addOAuthService("google");
oauthConfig.setAccessTokenUrl("https://www.google.com/accounts/OAuthGetAccessToken");
oauthConfig.setRequestTokenUrl("https://www.google.com/accounts/OAuthGetRequestToken?scope=" + scope);
oauthConfig.setAuthorizationUrl("https://www.google.com/accounts/OAuthAuthorizeToken");
oauthConfig.setConsumerKey("anonymous");
oauthConfig.setConsumerSecret("anonymous");
var requestData = {
//"muteHttpExceptions": true,
"method": "GET",
"oAuthServiceName": "google",
"oAuthUseToken": "always"
};
//var url = "https://spreadsheets.google.com/feeds/download/spreadsheets/Export?key=" + ssID
var url = "https://docs.google.com/spreadsheets/d/" + ssID
+ "/feeds/download/spreadsheets/Export?"
+ "&size=A4" + "&portrait=true" +"&fitw=true" + "&exportFormat=" + format;
var result = UrlFetchApp.fetch(url , requestData);
var contents = result.getContent();
return contents;
}
감사합니다.
최신 답변은 다음과 같습니다. http://stackoverflow.com/questions/31809987/google-app-scripts-email-a-spreadsheet-as-excel –