Question

I'm trying to get a hitbox auth token for like 2 days but still just getting the same Error: "Bad Request" and as response content "auth_failed". All I found in the huge Internet didn't help. :C

So.. I'm using Restsharp, which worked fine for normal HTTP URL requests (yey ...)

The documentation for hitbox is pretty short (http://developers.hitbox.tv/token) ... so not much help there

(I know that there are much questions of this Topic out there, tried most, but still same response...)

So that's my Code atm:

  public static void GetAuthToken(object user)
  {
       var client = new RestClient();
       client.BaseUrl = "http://api.hitbox.tv/";

       var request = new RestRequest("auth/token", Method.POST) { RequestFormat = DataFormat.Json };
       request.AddBody("login=Zetter&pass=MyPassword&app=MyAppName");

       var response = client.Execute(request);
       Console.Out.WriteLine(response.StatusDescription);
       Console.Out.WriteLine(response.Content);
  }

As I said. Tried very much, but for now I minimized the Code back to the original Code.

Thanks in advance. :)

Was it helpful?

Solution

Finally I found a way to do it. It's much easier than I first thought.

public static void GetAuthToken(object user)
{
    var client = new RestClient();
    client.BaseUrl = "http://api.hitbox.tv";
    client.Authenticator = new SimpleAuthenticator("login", "Zetter", "pass", "MyPassword");
    var request = new RestRequest("auth/token/", Method.POST);
    var response = client.Post(request);
}

Now the auth token can be found in the response...

Well the "app" value is missing. So I researched in the source files of Restsharp and found this solution:

public static void GetAuthToken(object user)
{
    var client = new RestClient();
    client.BaseUrl = "http://api.hitbox.tv";

    var request = new RestRequest("auth/token/", Method.POST);
    request.AddParameter("login", "Zetter");
    request.AddParameter("pass", "MyPassword");
    request.AddParameter("app", "AppName");

    var response = client.Post(request);
}

Well that's coding ... xD

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top