4

For background information, I'm using TweetSharp 1.0 to do my tweeting. Callback urls are being recieved regardless of whether they contain a querystring parameter (CallbackConfirmed is true) but they don't redirect upon authorization when they have contain a querystring parameter. They head off to twitter looking fine and dandy (example: http://api.twitter.com/oauth/authorize?oauth_token=MYTOKENREMOVED&oauth_callback=http://www.mywebsite.co.uk?q=Woop%20Woop) but when twitter is supposed to redirect to the callback url, it just redirects them to twitter.com.

This appears to only happen when I use spaces in the callback url - oauth_callback=http://www.mywebsite.co.uk?q=Woop_Woop works whereas oauth_callback=http://www.mywebsite.co.uk?q=Woop%20Woop does not.

Mr Grok
  • 3,876
  • 5
  • 31
  • 40

2 Answers2

4

Any querystring parameters you supply must be url encoded. Spaces should become "+" and not %20 (Server.UrlEncode will do the job in .NET). %20 is not the same as + so oauth_callback=http://www.mywebsite.co.uk?q=Woop%20Woop should become: oauth_callback=http://www.mywebsite.co.uk?q=Woop+Woop

In addition ... Server.UrlEncode will not quite work because "Hexadecimal characters in encodings MUST be upper case" (see section 5.1 of http://oauth.net/core/1.0/) and C# encodes to lowercase. I believe JavaScript also encodes to lower rather than uppercase. For C# a quick solution to the lowercase encoding problem can be found at: .net UrlEncode - lowercase problem

Community
  • 1
  • 1
Mr Grok
  • 3,876
  • 5
  • 31
  • 40
  • I'm just encountering this myself, and if I use + instead of %20, it does redirect back to the + version of the URL, however my problem now is the web application doesn't recognize + instead of %20 in the url :( Any ideas? – Redth Mar 01 '12 at 16:34
0

For whatever reason I was never able to get this to work. But for anyone in the same situation, before banging your head against the wall for hours, note you can likely achieve the same effect using cookies or session instead of querystring parameters. (Unless those aren't options, of course)

Dax Fohl
  • 10,654
  • 6
  • 46
  • 90