hey man.
bunch of useful crap
here.
register your application (even for test purposes)
here.
this will generate a client id and secret key you will then use to authenticate users.
check out the esi interface
here, you'll want to use this over all the old methods.
in theory, it could look something like this.
user hits login button which will re-direct to ccp and grab an authentication code for the character they want to use:
[HttpPost]
public RedirectResult Index()
{
string redirect_url = "http://localhost/ropeyevetest/index/callbackaction";
string clientid = "CLIENT ID FROM APPLICATION REGISTRATION";
string scope = "esi-location.read_location.v1";
string url = $"https://login.eveonline.com/oauth/authorize/?response_type=code&redirect_uri={redirect_url}&client_id={clientid}&scope={scope}";
return Redirect(url);
}
redirect url is where ccp will post back to with the authorisation code & you set this up when you regiser your app.
scope are the apis you seek permission to access for the given character; in this instance just character location.
when the user hits authorize, they'll drop back into your callback url.
here you could do something like this:
public ActionResult CallbackAction()
{
string auth_code = Request.Params["code"];
// now we can use the authorization code to grab an access token.
using (var client = new WebClient())
{
// build and apply the authorisation header.
string clientid = "CLIENT ID FROM APPLICATION REGISTRATION";
string secret = "SECRET KEY FROM APPLICATION REGISTRATION";
string auth_header = $"{clientid}:{secret}";
string auth_header_64 = $"Basic {Convert.ToBase64String(Encoding.UTF8.GetBytes(auth_header))}";
client.Headers[HttpRequestHeader.Authorization] = auth_header_64;
// build the post parameters.
var post_params = new NameValueCollection();
post_params.Add("grant_type", "authorization_code");
post_params.Add("code", auth_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);
}
return View();
}
the response is just a json object, which contains an access token you can use over and over to call the permitted apis.
read the linked site for more info about the refresh token, etc.
calling an API is then as simple as this:
[HttpPost]
public ActionResult Locate(string command)
{
string access_token = "ACCESS TOKEN FROM CCP";
using (var client = new WebClient())
{
// apply the authorisation header.
string auth_header = $"Bearer {access_token}";
client.Headers[HttpRequestHeader.Authorization] = auth_header;
string response = client.DownloadString("https://esi.tech.ccp.is/latest/characters/SOME-CHARACTER-ID/location/");
}
return View();
}
etc.