In the process of porting Xamarin.Auth to Windows 8 I came across the following problem. When trying to authenticate to LinkedIn using OAuth2 and Requesting an Access Token by exchanging the authorization code for it https://developer.linkedin.com/documents/authentication, Xamarin.Auth tries to parse the result (A JSON object) as if it were a url formatted string. In RequestAccessTokenAsync (OAuth2Authenticator.cs) there is the following code
var text = task1.Result.GetResponseText(); [JSON object]
var data = WebEx.FormDecode(text);
Am I missing something? Is this a bug in the Xamarin.Auth code? Do all OAuth2 based websites return JSON objects in this scenario, and if not how would one determine the type of format the result is in, other than trying to look for indicators in the result itself?
Update:
I edited the GetResponseText extension to return the type of content, in this case application/json and used Json.Net to parse the Json as the GetValueFromJson function in the framework does not work for the json returned in this scenario.
After working with this framework for a couple of days, it seems to be a "Beta" version, I will have to extensively modify it in order for it to be portable across Win8, WP8, iOS and Android.
e.g. Expect100Continue not supported in W8, will have to remove HttpWebRequest and replace with HttpClient.
e.g. LinkedIn requires a header to be set in order to return Json, these kinds of option need to be made available to the caller of the framework.
e.g. ContentType parsing needs to be completed as per the relevant specifications.
I believe you have outdated source, Xamarin.Auth gained the ability to handle JSON auth token responses a month ago: https://github.com/xamarin/Xamarin.Auth/commit/f21773a52f58b9d82f3adf38acba509fa0e9aecc#L3L311
Issues with this library are better reported as issues: https://github.com/xamarin/xamarin.auth/issues
There is an
experimental-winphone
branch I pushed last week that adds a Windows Phone 8 library and replaces the core with HttpClient to properly support disabling Expect100Continue on other platforms.