Any Idea out there? I tried following to no avail: a. Did the entire process (starting from registering the app and generating consumer key/secret to getting Access Token/secret. Works fine till I get Access Token & Secret b. When I copy/paste complete URL in browser's address bar, it prompts for credentials saying - "The server twitter.com:80 at Twitter API requires a username and password". Wondering if port 80 is the problem? But I think oAuth documentation states this as default behaviour and I see no documentation on twitter to provide Port number in URL. c. Ran my program with both scenarios – logged in and logged out from the twitter account in a browser. d. Tried with both “/verify_credentials.xml” and “/user_timeline.xml”
More notes about the application: 1. .net 3.5/C# 2. Desktop/Console application 3. Using http://oauth.googlecode.com/svn/code/csharp/OAuthBase.cs as the base and extended it to suit desktop/PIN related bits. 4. Stored Access Token and Secret in a text file and copy/pasted in code as a consts (just if this matters. I cross checked the characters). 5. The Twitter account shows application in Setting>Connection and Setting>Connection Browse. I do not think this could be an issue that the account for both is same. 6. Pseudocode (to access protected resources) a. Generate Signature, Request URL and parameter with URI, consumer key, consumer secret, token key and token secret b. Concatenate Request URL, Parameters and Signature to form final URL c. Create HttpWebRequest object with URL d. Set HttpWebRequest object’s method to GET e. Set ServicePoint.Expect100Continue to false f. Set UserAgent g. Timeout 2000 h. Get a new StreamReader from HttpWebRequest.GetResponse ().GetResponseStream i. StreamReader.ReadToEnd (ERROR!) 7. Stack Trace • at System.Net.HttpWebRequest.GetResponse() • at OAuthWalkthroughConsole.WebHelper1.WebResponseGet(HttpWebRequest webRequest) in D:\Development\POC\TwitterPrototype \ConsoleTest2\ConsoleTest2\Program.cs:line 193 • at OAuthWalkthroughConsole.WebHelper1.WebRequest(String method, String url, String postData) in D:\Development\POC\TwitterPrototype \ConsoleTest2\ConsoleTest2\Program.cs:line 168 • at OAuthWalkthroughConsole.Program.Main() in D:\Development\POC \TwitterPrototype\ConsoleTest2\ConsoleTest2\Program.cs:line 40 • at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args) • at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) • at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly () • at System.Threading.ThreadHelper.ThreadStart_Context(Object state) • at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) • at System.Threading.ThreadHelper.ThreadStart() How I wish Twitter returned more detailed errors! I could not make anything of “401 Unauthorized”. Is it wrong token/key or the encoding or the parameters, what? Does Twitter API still have issues giving access to PIN based Token/ Secret from desktop clients? But I see many people got access. Is the behaviour (of getting access through desktop) consistent? What is going wrong here? On Dec 15, 4:48 am, Sanjay <[email protected]> wrote: > I got my desktop application registered on Twitter and successfully > got the PIN which I used to generate Token and Secret Key. I am > generating following signature for verify_credentials: > > http://twitter.com/account/verify_credentials.xml?oauth_consumer_key=... > > It always returns 401 Unaushorized error. Am I missing something. The > Response Header below: > > Response Object Header > {Status: 401 Unauthorized > X-Runtime: 0.00163 > Vary: Accept-Encoding > Connection: close > Content-Length: 419 > Cache-Control: no-cache, max-age=1800 > Content-Type: application/xml; charset=utf-8 > Date: Mon, 14 Dec 2009 23:34:46 GMT > Expires: Tue, 15 Dec 2009 00:04:46 GMT > Set-Cookie: > _twitter_sess=BAh7BzoHaWQiJWZhYWE0ZjgwOTY4ZDA5ZDIzMjRjOTVmY2UxMmNlOWM1Igpm > %250AbGFzaElDOidBY3Rpb25Db250cm9sbGVyOjpGbGFzaDo6Rmxhc2hIYXNoewAG > %250AOgpAdXNlZHsA--482b347c66dc8e1643fcf1b99a82f36aeee38f41; > domain=.twitter.com; path=/ > Server: hi > WWW-Authenticate: Basic realm="Twitter API" > > > > }
