I'm building an iPhone app with Appcelerator (http:// appcelerator.com), and have run into some problems with OAuth implementation. I'm making calls to request_token, that work fine from a browser (Safari, Firefox) when I test in a static HTML page.
When I make essentially the same calls inside the iPhone simulator or on an iPhone device running the application, I always get 502 errors. I ran a sniffer to compare the requests to /request_token, and they are only different by minimal changes to the headers -- could someone give me an idea what's going wrong here? These are the headers of a working request from a browser: REQUEST (working): Content-Length: 0 Accept: */* Accept-Language: en-us Origin: file:// Cache-Control: max-age=0 Connection: keep-alive User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_2; en-us) AppleWebKit/531.21.8 (KHTML, like Gecko) Version/4.0.4 Safari/ 531.21.10 Accept-Encoding: gzip, deflate Content-Type: application/x-www-form-urlencoded Authorization: OAuth realm="",oauth_consumer_key="xxx",oauth_token="",oauth_version="1.0",oauth_timestamp="1262832498",oauth_nonce="loxEaw",oauth_signature_method="HMAC- SHA1",oauth_signature="xxx" Host: twitter.com RESPONSE (working): Server: hi Vary: Accept-Encoding Last-Modified: Thu, 07 Jan 2010 02:48:19 GMT Cache-Control: no-cache, no-store, must-revalidate, pre-check=0, post- check=0 ETag: "0793e0ee4fb1787d334a3540299ba3fd"-gzip Status: 200 OK Date: Thu, 07 Jan 2010 02:48:19 GMT Expires: Tue, 31 Mar 1981 05:00:00 GMT Pragma: no-cache X-Runtime: 0.00667 X-Transaction: 1262832499-17156-18234 X-Revision: DEV Set-Cookie: _twitter_sess=... Content-Encoding: gzip Content-Type: text/html; charset=UTF-8 Content-Length: 148 Connection: close And here's from the requests that do not work in the iPhone environment: REQUEST (not-working - 502): Accept-Encoding: gzip, deflate Accept-Charset: utf-8,windows-1252,shift_jis,iso-8859-1 Accept: */* Accept-Language: en-us Content-Length: 0 Connection: keep-alive User-Agent: Mozilla/5.0 (iPhone Simulator; U; CPU iPhone OS 3_1_2 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Mobile/7D11 Titanium/0.8.2 X-Requested-With: XMLHttpRequest Authorization: OAuth realm="",oauth_consumer_key="K3IwQ4AIIwmaxbUKkbI8qQ",oauth_token="",oauth_version="1.0",oauth_timestamp="1262818872",oauth_nonce="clxJcl",oauth_signature_method="HMAC- SHA1",oauth_signature="%2F63JkPaTW4ZZMIzizk%2Bhb9WY9fg%3D" Content-Type: application/x-www-form-urlencoded Host: twitter.com RESPONSE (not-working - 502): Content-Length: 1704 Content-Encoding: gzip Server: Apache Connection: close Last-Modified: Wed, 06 Jan 2010 20:16:24 GMT Vary: Accept-Encoding Content-Type: text/html; charset=UTF-8 Date: Wed, 06 Jan 2010 23:01:12 GMT Accept-Ranges: bytes Any ideas on where to go with this would be helpful....thanks, greg.