googleworkspace/apps-script-oauth1

<wbr> tags resulting in 401 errors

Iwanjka opened this issue · 4 comments

I am programming in Google Script. Since migrating towards oath1 (I use the shared libray posted on github, thanks for that!!!) I seem to get errors caused by '' tags in the urls.

I tried switching of 'escaping' (via the parameters). As far as I can see the '' tag is added after I do the fetch via the auth1 service clas...

The actual code is like this:

var requestData = {
"method": "POST",
"escaping":false
};

var result = service.fetch(url,requestData);

The error I get (with Dutch keywords, I hope this is not a problem, i replaced the wbr tag by WBRTAG otherwise it is replaced by a return when viewing):

20:39doSomeTriggeredThingsVerzoek voor https://api.twitter.com/1.1/WBRTAGstatuses/update.json?status=WBRTAGNieuw%20bij%20BoekenRoute%3A%WBRTAG20%22De%20avonturen%20van%WBRTAG20Alice%20in%20Wonderland%20%WBRTAG26%20Spiegelland%22%2C%WBRTAG20Lewis%20Carroll%2C%20%WBRTAG20Uitgeverij%20...%22

Foutcode: 401. Ingekorte serverreactie: {"errors":[{"code":32,"message":"Could not authenticate you."}]} (Gebruik de optie muteHttpExceptions om de volledige reactie te onderzoeken.) (regel 423, bestand 'Service', project 'OAuth1'

Anyone any ideas? It happens not 'all the time'... maybe say 1 out of 10 calls?

THANK YOU!
Iwanjka (Netherlands / Malawi)

This looks like the same kind of mysterious insertion...
https://www.drupal.org/node/332499
a new observation is that some days the insertions stays away, and that for instance a week later it starts again... strange!

Strange, I've never seen those tags before. What does your code look like?

Erick, thank you for responding...

The code sniplet looks like this:
[the passed service object has been created via the oauth1 github class, i added two 'text searches' to check if the 'wbr' items are generated in 'my own code', as far as i can see this is not happening (i don't get notification emails, so the 'wbr' tags myst arise somewhere deeper in the 'protocol stack')]

Iwanjka (iwanjka@gmail.com)

function atomicTwitterAPICall1_1_statuses_update(theParametersString,service){
// * Specification:
// * Pass everything which is passed normally after 'json?'

// see remark James Petersen: escaping false
var requestData = {
"method": "POST",
"escaping":false
};

var theBaseURL = "https://api.twitter.com/1.1/statuses/update.json?";
var theCompleteCallURL = theBaseURL + theParametersString;

var url = theCompleteCallURL;
logTwitterAPIPrePostDetail("logTwitterAPIPrePostDetail - Pre - function atomicTwitterAPICall1_1_statuses_update(), the completer URL: "+theCompleteCallURL);
MasterMixerProject.setTwitter_Active_URL_Call(iAm,theCompleteCallURL);
//service = getTwitterService();

var indexWBR = theCompleteCallURL.indexOf("%3Cwbr%3E"); // =
if (indexWBR>-1){
MailApp.sendEmail("iwanjka@gmail.com", "EUREKA INTERCEPTED in post","");
}

// Find out where 'wbr' comes from... non escaped version:
var indexWBR = theCompleteCallURL.indexOf("wbr"); // wbr
if (indexWBR>-1){
MailApp.sendEmail("iwanjka@gmail.com", "EUREKA INTERCEPTED wbr in post","");
}

var result = service.fetch(url,requestData);

You should no longer be disabling escaping when posting to twitter. See the Twitter sample for the correct usage: https://github.com/googlesamples/apps-script-oauth1/blob/master/samples/Twitter.gs