C# SSO call gives 400 when I try to get a token

Hey guys,

I am stuck here. This should work, but I get a http 400 instead of a token. I really ould like to work through this and understand the mechanics myslef instead of using a library. Do i do anything wrong here? See code:

 private void GetToken(String codeStr)
    {
        WebClient request = new WebClient();
                             
        string auth_header = $"{clientID}:{secretKey}";
        string auth_header_64 = $"Basic {Convert.ToBase64String(Encoding.UTF8.GetBytes(auth_header))}";
        request.Headers[HttpRequestHeader.Authorization] = auth_header_64;
        var post_params = new NameValueCollection();
        post_params.Add("grant_type", "authorization_code");
        post_params.Add("code", codeStr);

        byte[] response = request.UploadValues($"https://login.eveonline.com/oauth/token", "POST", post_params);
        string actual_response = Encoding.UTF8.GetString(response);

        MessageBox.Show(actual_response);
    }

Try setting a Content-Type: application/x-www-form-urlencoded header and making sure your values are properly escaped.

Also, whats the error you get back?

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.