我正在使用电子邮件奥迪 API 以加密形式下载用户的邮箱。当我将代码写入谷歌脚本并尝试运行时,它会给出错误 504:超时错误。当我使用 OAuth 游乐场执行此操作时,我成功下载了邮箱。 .所以请给我一些建议来解决这个问题。
Code :
function downloadMailBox(user){
var user='user@mydomain.com'
var base='https://apps-apis.google.com/a/feeds/compliance/audit/'
var fetchArgs=googleOAuth_('google',base)
var userID=user.split('@')[0]
//Logger.log(userID)
var rawXml='<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:apps="http://schemas.google.com/apps/2006">'+
'<apps:property name="packageContent" value="FULL_MESSAGE"/></atom:entry>'
fetchArgs.payload=rawXml
var uriForMailbox=base+'mail/export/mydomain.com/'+userID
UrlFetchApp.fetch(uriForMailbox,fetchArgs)
}
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("mydomain.com");
oAuthConfig.setConsumerSecret(consumersecret);
return {oAuthServiceName:name,
oAuthUseToken:"always",
contentType:'application/atom+xml',
method:'POST'
};
}