I could use some help please. I am trying to create a C# console app that gets an access key from a refresh token. Obviously my end program does far more, but I’m stuck here. I obtained the refresh key from postman, so this is my first attempt to use c# to interact with EvE ESI. Here is my code:
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp1
{
class Program
{
static HttpClient client = new HttpClient();
static async Task RunAsync()
{
string clientid = "<<client_id>>";
string secret = "<<secret>>";
string auth_header = $"{clientid}:{secret}";
string auth_header_64 = $"Basic {Convert.ToBase64String(Encoding.UTF8.GetBytes(auth_header))}";
string refreshtoken = "<<refresh Token>>";
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/x-www-form-urlencoded"));
client.DefaultRequestHeaders.Clear();
client.DefaultRequestHeaders.Add("Authorization", auth_header_64);
HttpResponseMessage response;
try
{
response = await client.GetAsync($"https://login.eveonline.com/oauth/token?grant_type=refresh_token&refresh_token={refreshtoken}");
if (!response.IsSuccessStatusCode)
{
Console.WriteLine("Error refreshing token");
Console.WriteLine(response.ToString());
return;
}
string data = await response.Content.ReadAsStringAsync();
Console.WriteLine(data);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
static void Main(string[] args)
{
RunAsync().GetAwaiter().GetResult();
}
}
}
Here is the response that I am getting:
Error refreshing token
StatusCode: 404, ReasonPhrase: 'Not Found', Version: 1.1, Content: System.Net.Http.HttpConnection+HttpConnectionResponseContent, Headers:
{
Cache-Control: private
Server: Microsoft-IIS/10.0
Date: Mon, 22 Apr 2019 03:19:24 GMT
Content-Type: text/html
Content-Length: 0
}
Thank you in advance for your help.