I am getting an error in my WPF C# application:
private void login_click(object sender, RoutedEventArgs e)
{
string clientID = "---------------------";
string clientSecret = "-----------------";
string scope = "channel_editor channel_commercial";
string redirectUri = "http://localhost";
string authUrl = "https://api.twitch.tv/kraken/oauth2/authorize";
try
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(authUrl);
string authData = "?response_type=code&client_id=" + clientID +
"&redirect_uri=" + Uri.EscapeDataString(redirectUri) +
"&scope=" + scope;
byte[] authByte = Encoding.UTF8.GetBytes(authData);
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = authByte.Length;
Stream postStream = request.GetRequestStream();
postStream.Write(authByte, 0, authByte.Length);
postStream.Close();
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
}
catch (WebException error)
{
MessageBox.Show(error.ToString());
}
}
When I run this code, the response triggers an exception:
The remote server returned an error: (404) Not Found.
Confused on why this is happening.