Good day, I am writing an iOS app that needs to authenticate with Twitter. When I POST a request to https://api.twitter.com/oauth/request_token I get a 401 error with the message “Failed to validate oauth signature and token”.
Here is an example of a base string I generated:
POST&https%3A%2F%2Fapi.twitter.com%2Foauth%2Frequest_token&oauth_callback%3Doob%26oauth_consumer_key%3Dfy5lC1V4ojgaolKPnEsbg%26oauth_nonce%3D364f54142f207e087b0061b0ff4fa60c269b5419%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1315410646%26oauth_version%3D1.0
Can’t see anything wrong with it. I also checked my signature generation method using the example base string and consumer secret in the Twitter documentation here: https://dev.twitter.com/docs/auth/oauth
I get the same signature.
I also checked my timestamp but it is within a second of UTC epoch time. Here are the response headers I’m getting:
Response:{
“Cache-Control” = “no-cache, no-store, must-revalidate, pre-check=0, post-check=0”;
Connection = close;
“Content-Encoding” = gzip;
“Content-Length” = 62;
“Content-Type” = “text/html; charset=utf-8”;
Date = “Wed, 07 Sep 2011 15:50:48 GMT”;
Expires = “Tue, 31 Mar 1981 05:00:00 GMT”;
“Last-Modified” = “Wed, 07 Sep 2011 15:50:48 GMT”;
Pragma = “no-cache”;
Server = hi;
“Set-Cookie” = “admobuu=30ed26ca874a682abe8f02dde910b6b4; domain=.m.twitter.com; path=/; expires=Tue, 19 Jan 2038 03:14:07 GMT, _twitter_sess=BAh7CDoPY3JlYXRlZF9hdGwrCDOclUQyAToHaWQiJTYyN2Q1YTlkOWRlYTky%250AYjNmMzhkY2NhMDIxZmZjYjc2IgpmbGFzaElDOidBY3Rpb25Db250cm9sbGVy%250AOjpGbGFzaDo6Rmxhc2hIYXNoewAGOgpAdXNlZHsA–4fa77deaa5e2a9b3fd9817d3e2bd5562fa495c00; domain=.twitter.com; path=/; HttpOnly”;
Status = “401 Unauthorized”;
Vary = “Accept-Encoding”;
“X-Content-Type-Options” = nosniff;
“X-Frame-Options” = SAMEORIGIN;
“X-Mid” = 70704cf1e07711a4e1e26b9370f61004030eebff;
“X-Revision” = DEV;
“X-Runtime” = “0.00468”;
“X-Transaction” = “1315410648-37419-22715”;
}
What could I be doing wrong?