Closed Lakritzator closed 8 years ago
One way of going forward is having the "Json" classes available public (not internal) and also all the information like the Uri, so we make a simple implementation which handles most simple stuff and everything else can be handled in the calling application.
In that way, Dapplo or another client can be used.
BUT, I at least want to change from HttpWebRequest to HttpClient which is more modern/current.
Done.
I had a quick look at the "GetUserAuthToken" method implementation, which gets a token via a login at Logitech. This is written with HttpWebRequest, the implementation will cause issues when someone is behind a proxy. (This is why I wrote Dapplo.HttpExtensions, as most people implement HTTP calls wrong)
Just for fun, here is an implementation of the GetUserAuthToken with Dapplo.HttpExtensions:
< promotion mode on >
Here the original:
Advantage old vs new:
Disadvantage new vs old:
Advantage new vs old:
and most importantly it has error checking: it processes the Json response depending on an HTTP error differently! It either gives a normal response (as before, when no error) or an UserAuthErrorDetails when there was an error... packed in a wrapper, but you can write your own, where you can just check "if (result.HasError)" and e.g. create an exception which in case of a bad password passes the error message from logitech and looks like this:
Authentication failure BadCredentials : Unable to authenticate user's mail with the corresponding password via LIP:: 1234@domain.com </ promotion mode off >