Yes, that’s correct. I get a token during the request portion, I get redirected to the twitter login / authorization page, and then when it redirects back to my site, my site tells me that twitter’s response to the access_token endpoint is “Invalid / expired Token”.
I have my site spitting out a bunch of debugging messages right now along each step of the way, so I can see where it’s going wrong. I know it’s not the raw HTTP requests like you wanted, but I think it’s providing the same data you were asking for (but after a little parsing into some arrays and objects).
(let me know if this isn’t useful to you and I can try to dig for more information, it’s just buried in there somewhere amongst different modules so it’s sometimes hard to find
)
Some explanation of what these messages are saying:
First, we make a POST request to oauth/request_token
auth_request method called from get_request_token
response:stdClass Object
(
[request] => POST /oauth/request_token HTTP/1.1
Authorization: OAuth oauth_consumer_key=“jPBEGdcURg1Yo7kAGFqnA”,oauth_nonce=“ba19f276ed50400136ef82347b1ffed6”,oauth_signature=“J%2FNUl5u%2F9rvoz3Xx3teog8nNdEc%3D”,oauth_signature_method=“HMAC-SHA1”,oauth_timestamp=“1322701894”,oauth_version="1.0"
Accept: /
Content-Type: application/x-www-form-urlencoded
User-Agent: Drupal
Host: api.twitter.com
Content-Length: 0
[data] => oauth_token=Mr4WyhTq64bebKqg4zStb2cB505PNyZ9Cv2t2o0ymI&oauth_token_secret=FTPXSuWaq3PV7FuXIfVcOeuiLsYjcjMTlaJL6v7Q&oauth_callback_confirmed=true
[protocol] => HTTP/1.1
[status_message] => OK
[headers] => Array
(
[date] => Thu, 01 Dec 2011 01:11:34 GMT
[status] => 200 OK
[x-transaction] => 2b2458c44a38e77c
[etag] => "77133197d7261bc7e52e93db58b63405"
[x-frame-options] => SAMEORIGIN
[last-modified] => Thu, 01 Dec 2011 01:11:34 GMT
[x-runtime] => 0.01411
[content-type] => text/html; charset=utf-8
[content-length] => 144
[pragma] => no-cache
[x-revision] => DEV
[expires] => Tue, 31 Mar 1981 05:00:00 GMT
[cache-control] => no-cache, no-store, must-revalidate, pre-check=0, post-check=0
[x-mid] => 0d21a8391803f29b52e9f3b1f42e00d37dbe0a9a
[set-cookie] => k=10.34.231.124.1322701894448652; path=/; expires=Thu, 08-Dec-11 01:11:34 GMT; domain=.twitter.com,guest_id=v1%3A132270189445747723; domain=.twitter.com; path=/; expires=Sat, 30-Nov-2013 13:11:34 GMT,_twitter_sess=BAh7CDoPY3JlYXRlZF9hdGwrCDozLfczAToHaWQiJWViMmZjNDUzNTFmOTAx%250AMjM5ZDY4Y2M2ZDJmYTJiMzM5IgpmbGFzaElDOidBY3Rpb25Db250cm9sbGVy%250AOjpGbGFzaDo6Rmxhc2hIYXNoewAGOgpAdXNlZHsA--3d65b3b590c61fdad11ff09fc80ca8869546a440; domain=.twitter.com; path=/; HttpOnly
[vary] => Accept-Encoding
[server] => tfe
)
[code] => 200
)
You can see from the response that it gave me back an oauth_token which I then spit out in some more debugging messages:
post rv:oauth_token=Mr4WyhTq64bebKqg4zStb2cB505PNyZ9Cv2t2o0ymI&oauth_token_secret=FTPXSuWaq3PV7FuXIfVcOeuiLsYjcjMTlaJL6v7Q&oauth_callback_confirmed=true
token response: Array
(
[oauth_token] => Mr4WyhTq64bebKqg4zStb2cB505PNyZ9Cv2t2o0ymI
[oauth_token_secret] => FTPXSuWaq3PV7FuXIfVcOeuiLsYjcjMTlaJL6v7Q
[oauth_callback_confirmed] => true
)
Debugging message tells me the authenticate page url before it redirects to it (to make sure I was getting that right):
authenticate url:|https://api.twitter.com/oauth/authenticate?oauth_token=Mr4WyhTq64bebKqg4zStb2cB505PNyZ9Cv2t2o0ymI|
Debug message spits out the querystring from the callback function:
callback qs:Array
(
[oauth_token] => Mr4WyhTq64bebKqg4zStb2cB505PNyZ9Cv2t2o0ymI
[oauth_verifier] => sFg9aoRpZQhwzEGNOe4OOUVubjOwutHLVJv6mNRpvU
)
get_access_token get:Array
(
[q] => twitter/oauth
[oauth_token] => Mr4WyhTq64bebKqg4zStb2cB505PNyZ9Cv2t2o0ymI
[oauth_verifier] => sFg9aoRpZQhwzEGNOe4OOUVubjOwutHLVJv6mNRpvU
)
and then debug message spits out the results of the POST to oauth/access_token
auth_request method called from get_access_token
response:stdClass Object
(
[request] => POST /oauth/access_token HTTP/1.1
Authorization: OAuth oauth_consumer_key=“jPBEGdcURg1Yo7kAGFqnA”,oauth_nonce=“7bedcd2233a5d8a332d9c44a2cf4525b”,oauth_signature=“bZ2HuLVlHWpfE26HBnDloErpr80%3D”,oauth_signature_method=“HMAC-SHA1”,oauth_timestamp=“1322701946”,oauth_token=“Mr4WyhTq64bebKqg4zStb2cB505PNyZ9Cv2t2o0ymI”,oauth_version="1.0"
Accept: /
Content-Type: application/x-www-form-urlencoded
User-Agent: Drupal
Host: api.twitter.com
Content-Length: 57
oauth_verifier=sFg9aoRpZQhwzEGNOe4OOUVubjOwutHLVJv6mNRpvU
[data] =>
Invalid / expired Token
/oauth/access_token
[protocol] => HTTP/1.1
[status_message] => Unauthorized
[headers] => Array
(
[date] => Thu, 01 Dec 2011 01:12:27 GMT
[status] => 401 Unauthorized
[www-authenticate] => OAuth realm="https://api.twitter.com"
[x-transaction] => bb806dde7b4f476f
[x-frame-options] => SAMEORIGIN
[last-modified] => Thu, 01 Dec 2011 01:12:27 GMT
[content-type] => text/html; charset=utf-8
[content-length] => 136
[pragma] => no-cache
[x-revision] => DEV
[expires] => Tue, 31 Mar 1981 05:00:00 GMT
[cache-control] => no-cache, no-store, must-revalidate, pre-check=0, post-check=0
[x-mid] => 0acd28473b3bf6bf6badc7dd2188061d92e293ec
[set-cookie] => k=10.34.231.124.1322701947125301; path=/; expires=Thu, 08-Dec-11 01:12:27 GMT; domain=.twitter.com,guest_id=v1%3A132270194713256380; domain=.twitter.com; path=/; expires=Sat, 30-Nov-2013 13:12:27 GMT,_twitter_sess=BAh7CDoPY3JlYXRlZF9hdGwrCP0ALvczAToHaWQiJWJiNmJjMjVkNjRjZTcy%250AYzQwZDhkMTYyMmY0ZmVmYjQwIgpmbGFzaElDOidBY3Rpb25Db250cm9sbGVy%250AOjpGbGFzaDo6Rmxhc2hIYXNoewAGOgpAdXNlZHsA--fee03a788fffdf1f754678ffce21815231232637; domain=.twitter.com; path=/; HttpOnly
[vary] => Accept-Encoding
[server] => tfe
)
[code] => 401
[error] => Unauthorized
)
And that’s where I have the problem. You can see in the response I’m getting back from twitter that it’s saying “Invalid / expired Token” with a 401 Unauthorized… 