I am trying to access the Strava authentication API:
https://developers.strava.com/docs/authentication/
But I keep getting an "An existing connection was forcibly closed by the remote host" error, regardless of how I post my request server side using c#
I have tried both HttpClient and HttpWebRequest
var request = (HttpWebRequest)WebRequest.Create("https://www.strava.com/oauth/token");
var data = Encoding.UTF8.GetBytes("client_id=someid&client_secret=somesecret&refresh_token=sometoken&grant_type=");
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = data.Length;
using (var stream = request.GetRequestStream())
{
stream.Write(data, 0, data.Length);
}
var response = (HttpWebResponse)request.GetResponse();
var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
It works perfectly when using JavaScript, jQuery or Postman.
function doPost() {
$.post("https://www.strava.com/oauth/token",
{
client_id: "someid",
client_secret: "somesecret",
refresh_token: "sometoken",
grant_type: "refresh_token"
},
function (data, status) {
// done
});
}
Any help pointing me in the right direction will be greatly appreciated
Thnx