I’m currently playig a bit with Chrome extensions and the Twitter API and I’m stuck at the requesting of the userstream.
The Auth header I’m generating works, as I can successfully call the API via curl with it, but as soon as I want to make a request with it via XHR, the network tab is showing me the request as “pending”.
I added the twitter API to the permissions list in the extension manifest. This shouldn’t be the problem, as I get an Same-Origin error otherwise. Generating/Requesting Auth-Token with it works fine aswell.
Here’s the request Header as Chrome sends it:
GET https://userstream.twitter.com/2/user.json HTTP/1.1
Authorization: OAuth oauth_version="1.0", oauth_token="XXXXXXXX-XXXXXXXXXXXXXXXK1UgBBqCls8QGb1FAYU", oauth_consumer_key="XXXXXXXXXXXKPbUx3eA", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1341958387", oauth_nonce="doPiU4", oauth_signature="XXXXXXXXXXqiynLgAT5UIkHgiWk%3D"
User-Agent: Foo
Accept: */*
Cache-Control: max-age=0
this produces a “pending” reuest in Chrome, but the following curl request works as expected:
curl --get 'https://userstream.twitter.com/2/user.json' --header 'Authorization: OAuth oauth_version="1.0", oauth_token="XXXXXXXX-XXXXXXXXXXXXXXXK1UgBBqCls8QGb1FAYU", oauth_consumer_key="XXXXXXXXXXXKPbUx3eA", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1341958387", oauth_nonce="doPiU4", oauth_signature="XXXXXXXXXXqiynLgAT5UIkHgiWk%3D"' -A "Foo" --verbose
It produces basicly the same header
Figured it out:
The problem was that the missing “data” setting in jQuery. It seems their
$.ajaxfunction doesn’t like it when it’s missing, even for an empty GET request