Hello, I am trying to use the WWW object for OAuth implementation, and as per OAuth specification the server returns a HTTP Status code 400 along with some data to inform you what is wrong.
However, the WWW object gives me this exception when I try to read the response:
You are trying to load data from a www stream which had the following error when downloading.
400 Bad Request
Most probably you’'ll need to change the server response (it shouldn’t return an HTTP error, but a normal response - inside this response you should signalize the authentication error).
It will be generally easy if the server-side code is written by yourself, but don’t be afraid even if it isn’t (I had the similar problem - even had to change some of the Drupal (CMS) classes in order to make it work)
However, do not use anything else than WWW (or some wrapper classes), because only the WWW class is guaranteed to work across platforms (except Flash, with which you should write Actionscript in order to make the server call).
You might want to try this wrapper class in order to have the asynchronous syntax (no yields) - WebPlayer demo and usage here.
Altering the default OAuth 2.0 implementation in some kind way breaks with the standards and is something I would like to avoid if at all possible. Not to mention all the additional documentation I will have to type up, plus I’d have to recompile the DotNetOpenAuth package.
I guess there’s not a lot of choice open to me though. It’s either that or manually implement the connection layer in iOS instead using NSURLConnection, and work it through an interface. (Not very portable)
Thanks for the heads up, I’ll take a look at the code you linked, though the yields aren’t much of a problem.