These forums have been archived and are now read-only.
The new forums are live and can be found at https://forums.eveonline.com/
Looking for sample C# code to authenticate a user
[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);}
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();}
[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();}