EVE esi SSO problems. Need help retrieving token. ERR 400

I have tried several different languages in attempt to retrieve a token. Here is what I have with PHP/c#. So the initial PHP code is used for logon, and retrieving auth code. C# is used as the client side app and retrieving the token.

–LOGIN– [a link to select char and get a callback, works fine.]

<?php
$ssourl = “https://login.eveonline.com”;
$callback = “http://stuntitup.com/eve/esi/callback.php”;
$urlCallback = urlencode($callback);
$client_id = “xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx”;
$scope_location = “esi-location.read_location.v1”;
$urlauth = $ssourl."/v2/oauth/authorize/?response_type=code";
$urlauth = $urlauth."&redirect_uri=".$urlCallback;
$urlauth = $urlauth."&client_id=".$client_id;
$urlauth = $urlauth."&scope=".$scope_location;
$urlauth = $urlauth."&state=".“valid”;
echo “<a href=’”.$urlauth."’>Authorize</a>";
?>

–Call Back– [ Outputs auth code, works fine]
<?php
echo code = _REQUEST[‘code’];
?>

I then copy the above code, and paste it into the c# client in attempt to retrive a token.

—Client c#—- Different errors 40x

private void button3_Click(object sender, EventArgs e)
{

using (var client = new WebClient())
{

string Client_ID = “xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx”;
string Secret = “xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx”;
string code = “1L6IrMZNp0-OtX32-hX6xA”; //PASTE CODE HERE

    string auth_header = Client_ID + ":" + Secret;
    byte[] plainTextBytes = System.Text.Encoding.UTF8.GetBytes(auth_header);
    string auth_header_64 = System.Convert.ToBase64String(plainTextBytes);
    client.Headers[HttpRequestHeader.Authorization] = "Basic " + auth_header_64;
    client.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
    //client.Headers[HttpRequestHeader.Host] = "login.eveonline.com";

    // build the post parameters.
    NameValueCollection post_params = new NameValueCollection();
    post_params.Add("grant_type", "authorization_code");
    post_params.Add("code", code);
    
    // post info and grab the response.
     byte[] response = client.UploadValues("https://login.eveonline.com/oauth/token", "POST", post_params);
    
    string actual_response = Encoding.UTF8.GetString(response);
    }

}

The error I am getting for this one is “The remote server returned an error: (400) Bad Request”.

My thoughts are…

  1. Does the ESI server complain about me using a c# client mixed with php from a different server?
  2. Am I constructing the info to be sent properly?
  3. Should I try yet another language? lol…

Well for one, based on your code, you’re fetching the code from the v2 SSO endpoint, but POSTING it to the v1 endpoint.

HAHA, oh snap. Copy and paste links got the best of me. I will have to fix that part tomorrow and see if it helps.

That worked. :slight_smile: TYVM! Smh… so frustrating.

1 Like

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