Refresh token error 500

Hi,
I am new to ecboee API. I am working on web app and have gone through api documentation.
When I am trying to either refresh token or make any other request, I am getting 500 error
Refresh toke url : https://api.ecobee.com/1/token
Refresh token request:
{"grant_type":"refresh_token","code":"my auth code here","client_id":"my app code here"}

Thanks in Advance.
1 person has
this question
+1
Reply
  • Please follow the guidelines on providing the necessary data in order to diagnose your issue: http://developer.ecobee.com/api/topic...

    Without this information it is virtually impossible for us to figure out what is going wrong with your requests. I tried looking through our logs and it seems that you are making requests to obtain a token (/token) without passing in the 'code' that was returned by the prior '/authorize' call. It seems that your requests to the /token call are always with blank parameters rather than the required 'code','grant_type' and 'client_id' parameters as per the documentation https://www.ecobee.com/home/developer...
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. kidding, amused, unsure, silly indifferent, undecided, unconcerned sad, anxious, confused, frustrated happy, confident, thankful, excited

  • Kumar,

    Your URL is wrong. The authorization URLs do not have the version number in them as per the documentation: https://www.ecobee.com/home/developer...

    The URL you want is:


    https://api.ecobee.com/token
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. kidding, amused, unsure, silly indifferent, undecided, unconcerned sad, anxious, confused, frustrated happy, confident, thankful, excited

  • Thanks Mark,

    I tried without version, no I am getting following error

    The remote server returned an error: (400) Bad Request.

    I am using C# and newton.json lib

    my c# code

    var httpWebRequest = (HttpWebRequest)WebRequest.Create("https://api.ecobee.com/token");
    httpWebRequest.ContentType = "text/json";
    httpWebRequest.Method = "POST";

    using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
    {
    RefreshTokenRequest requestRefresh = new RefreshTokenRequest();
    requestRefresh.client_id = "myapp ket here";
    requestRefresh.code = Session["authorization_token"].ToString();
    requestRefresh.grant_type = "ecobeePin";

    streamWriter.Write(requestRefresh);
    streamWriter.Flush();
    streamWriter.Close();

    var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
    using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
    {
    var result = streamReader.ReadToEnd();
    var refresh = JsonConvert.DeserializeObject(result);

    Response.Write("Response:" + refresh.access_token + "access_token: " + refresh.token_type + "token_type: " + refresh.expires_in + "expires_in: " + refresh.refresh_token + "refresh_token: " + refresh.scope);
    Session["refresh_token"] = refresh.refresh_token;
    }
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. kidding, amused, unsure, silly indifferent, undecided, unconcerned sad, anxious, confused, frustrated happy, confident, thankful, excited

  • You need to provide the JSON response that you get along with the 400 error.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. kidding, amused, unsure, silly indifferent, undecided, unconcerned sad, anxious, confused, frustrated happy, confident, thankful, excited

  • Thank you for your patience Mark.

    I am attaching my fiddler screen shot with request /response. when I click on response json tab, it displays error message "The response does not contain valid JSON text"

    attached screen:

  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. kidding, amused, unsure, silly indifferent, undecided, unconcerned sad, anxious, confused, frustrated happy, confident, thankful, excited

  • This seems to be a problem with .NET clients. See a similar topic posted earlier here http://developer.ecobee.com/api/topic...

    The conclusion from that thread was "The .NET HttpClient sends an Expectation Header of 100 Continue which causes the API server to return a (417) Expectation Failed. This header needs to be disabled before making the post request."
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. kidding, amused, unsure, silly indifferent, undecided, unconcerned sad, anxious, confused, frustrated happy, confident, thankful, excited