Logging into WebAPI 2 site from c# desktop application
I was going to make a very large post with altered code, but I don't fully understand what your code is doing so all I will suggest is that


You need to use a consistent code style. camelCase for variables/arguments, PascalCase for runtime constants (types/constants) and properties, and _camelCase for private fields on an object.
Your methods are simply doing way too much. Your 2 methods there are connecting to two different web pages, composing two URLs, parsing JSON into a POCO (and then back out again), and doing authentication on top of all of that.
You aren't managing the lifecycle of HttpClient. There is a general consensus that creating and disposing HttpClients is not the best use of a class. At the very least you should be Disposing of your HttpClients but all you're doing in your current code is letting your HttpClients leak. Consider that your functions do not need to know how to create a HttpClient, they just need to know how to connect to a Url - let the caller of the function do the heavy lifting for you.


Once again I'd give you a code sample but I just don't understand what your code is trying to do, which is my own fault, because I haven't really used much HTTP in .NET.

Here are the responsibilities of your two methods so far:


Create a HttpClient
Decode JSON into a POCO
Create authentication token
Compose url from base url, secondary url and a query string
Apply authentication token to HttpClient
Handle the response of one of the HttpClients
Prepare HttpClient headers


The majority of these should be in their own function.