Google Apps Email Settings API का उपयोग करके नीचे दिए गए स्क्रिप्ट के साथ एक प्रतिनिधि हटा दिया जाता है। एक त्रुटि, होता है, तो उदाहरण के लिए प्रतिनिधियों मौजूद नहीं है कि हटाने का प्रयास करते हैं, तो निम्न संदेश दिया जाता है:muteHttpExceptions = सत्य प्रमाणीकरण विफलता फेंकता
अपवाद: < एक्सएमएल संस्करण = "1.0" एन्कोडिंग: अनुरोध लौटे कोड 400 संक्षिप्त किया गया सर्वर प्रतिक्रिया के लिए विफल रहा है = "UTF-8"? > < AppsForYourDomainErrors > < त्रुटि errorCode = "1303" invalidInput = "[email protected]" कारण = "ई ... (उपयोग muteHttpExceptions विकल्प पूरे जवाब का परीक्षण करने के लिए)
लेकिन जब muteHttpExceptions = true
का उपयोग कर प्रमाणीकरण विफल:
अपवाद: विफल सेवा को प्रमाणीकृत करने: गूगल
यह मुझे HTTPResponse
ऑब्जेक्ट की जांच करने के बजाय प्रयास/पकड़ संरचना का उपयोग करने के लिए मजबूर करता है। मैं जानना चाहता हूं कि यह क्यों हो रहा है और इसे कैसे हल किया जाए।
परीक्षण समारोह:
function test() {
var consumerKey = 'XXXX';
var consumerSecret = 'XXXX';
var domain = 'XXXX.com';
var userName = 'XXXX'
var delegateName = '[email protected]'
var serviceName = 'google';
var scope = 'https://apps-apis.google.com/a/feeds/emailsettings/2.0/';
var oAuthConfig = UrlFetchApp.addOAuthService(serviceName);
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(consumerKey);
oAuthConfig.setConsumerSecret(consumerSecret);
var fetchParameters = {};
fetchParameters.oAuthServiceName = serviceName;
fetchParameters.oAuthUseToken = 'always';
fetchParameters.method = 'DELETE';
fetchParameters.muteHttpExceptions = false;
try {
var url = 'https://apps-apis.google.com/a/feeds/emailsettings/2.0/'+ domain + '/' + userName + '/delegation/' + delegateName;
var result = UrlFetchApp.fetch(url, fetchParameters);
} catch (e) {
Logger.log(e);
}
}