XMLHttpRequest problem with sending signed request to Twitter API. No response.

216 views
Skip to first unread message

Kakysha

unread,
Sep 18, 2010, 9:29:26 AM9/18/10
to Chromium-extensions
I try to send signed oAuth XMLHttpRequest from background page from my
extension to ttp://api.twitter.com/1/statuses/update.json, but there
are no response from twitter, but all of the previous oAuth dance
steps successfully finished. It looks like a xhr just hangs or totally
close the connection before the answer received. For oAuth i use
popular library for JS - http://oauth.googlecode.com/svn/code/javascript/
from John Kristian. It was adviced on oauth.net

Twitter Api successfully gives me all the tokens (i use oAuth OOB) the
twitter
returns me a PIN code, then it successfully changed to acces token,
and on the final stage - attemp to update status it doesnt return any
response (((

I try to send Authorization header (i think, all right with it), and
i
try to send authorization fields directly in POST body, but nothing
((

My code is :
message = {method: "post", action: "http://api.twitter.com/1/statuses/
update.json",
parameters: [["status","Yahoo"]]};
var requestBody = OAuth.formEncode(message.parameters);
OAuth.completeRequest(message,
{ consumerKey : accessor.consumerKey
, consumerSecret: accessor.consumerSecret
, token : token
, tokenSecret : token_secret
});

var authorizationHeader = OAuth.getAuthorizationHeader("",
message.parameters);
var requestAction = new XMLHttpRequest();
requestAction.onreadystatechange = function() {
if (requestAction.readyState == 4) {
alert(requestAction.status+" "+requestAction.statusText
+"\n"+requestAction.getAllResponseHeaders()
+"\n"+requestAction.responseText);
}
};

requestAction.open(message.method, message.action, true);
requestAction.setRequestHeader("Authorization", authorizationHeader);
requestAction.setRequestHeader("Content-Type", "application/x-www-
form-
urlencoded");
requestAction.send(requestBody);

Arne Roomann-Kurrik

unread,
Sep 20, 2010, 3:34:06 PM9/20/10
to Kakysha, Chromium-extensions
Have you requested permissions for http://api.twitter.com in your extension's manifest?

~Arne



--
You received this message because you are subscribed to the Google Groups "Chromium-extensions" group.
To post to this group, send email to chromium-...@chromium.org.
To unsubscribe from this group, send email to chromium-extens...@chromium.org.
For more options, visit this group at http://groups.google.com/a/chromium.org/group/chromium-extensions/?hl=en.


Kakysha

unread,
Sep 20, 2010, 3:38:07 PM9/20/10
to Chromium-extensions
Yop, i also added "http://*/*" to permissions

On Sep 20, 11:34 pm, Arne Roomann-Kurrik <kur...@chromium.org> wrote:
> Have you requested permissions forhttp://api.twitter.comin your
> > To post to this group, send email to chromium-extensi...@chromium.org.
> > To unsubscribe from this group, send email to
> > chromium-extensions+unsubscr...@chromium.org<chromium-extensions%2Bunsubscr...@chromium.org>
> > .

Arne Roomann-Kurrik

unread,
Sep 20, 2010, 3:45:52 PM9/20/10
to Kakysha, Chromium-extensions
Then would it be possible for you share a copy of the extension with me?  I'm not seeing anything else obvious right now.

~Arne


To post to this group, send email to chromium-...@chromium.org.
To unsubscribe from this group, send email to chromium-extens...@chromium.org.

Kakysha

unread,
Sep 20, 2010, 3:51:02 PM9/20/10
to Chromium-extensions
Sended to your email. The logic is in background.html.
> > <chromium-extensions%2Bunsubscr...@chromium.org<chromium-extensions%252Bunsubscr...@chromium.org>
Reply all
Reply to author
Forward
0 new messages