shawn313
(shawn313)
June 27, 2019, 3:57am
1
I am using WebClient to make the request and keep getting a 401 error here is my code
public void OnGet()
{
Code = Request.Query["code"];
string username = "******";
string password = "*********";
using (var wc = new System.Net.WebClient())
{
string credentials = String.Format("{0}:{1}", username, password);
byte[] bytes = Encoding.ASCII.GetBytes(credentials);
string base64 = Convert.ToBase64String(bytes);
string authorization = String.Concat("basic ", base64);
string parameters = string.Concat("grant_type=", "authorization_code", "&code=", Code);
string url = "https://login.eveonline.com/oauth/token?"+parameters;
wc.Headers.Add("Authorization", authorization);
wc.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
wc.Headers.Add("Host", "login.eveonline.com");
string result = wc.UploadString(url, "");
bodycode = result;
}
}
any ideas?
Are your really passing a username and password? Or are those just poorly named clientid and secret?
I don’t know if it will make a difference, as, net is not my language, but, the request is meant to be post and you’re appending the values to the url (like a get request), but, they should be the second parameter of UploadString.
Something like:
string url = "https://login.eveonline.com/oauth/token";
…
wc.UploadString(url, parameters);
Edit:
Again, disclaimer, I don’t know anything about asp.net .
However, there are some .NET libraries, you may or may not be able to use on eve awesome:
https://github.com/devfleet/awesome-eve#net
@shawn313 You prob just need to use Basic
, notice the capital B
, in your Authorization
header.
system
(system)
Closed
September 27, 2019, 8:43pm
8
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.