sinricpro / non-sdk-issues

Report non sdk related issues here (Alexa, Google Home, SmartThings, IFTTT, API)
2 stars 0 forks source link

api refresh_token does not work #54

Closed Geromatic closed 1 year ago

Geromatic commented 1 year ago

Sample code

Some code omitted - converted nodejs to arduino http

  http.setURL("/api/v1/auth/refresh_token");
  http.addHeader("Content-Type", "application/json");

  DynamicJsonDocument root(1024);
  root["refreshToken"] = "<refresh_token>";
  root["accountId"] = "<account id>";

  String jsonString;
  serializeJson(root, jsonString);
  int httpResponseCode = http.sendRequest("GET", jsonString);

  Serial.print("HTTP Response code: ");
  Serial.println(httpResponseCode);

  jsonString = http.getString();
  Serial.println(jsonString);

Expect

Returns new access token and refresh token

Result

HTTP Response code: 422 {"success":false,"message":"\"accountId\" is not allowed"} Second attempt removed accountId HTTP Response code: 500 {"success":false,"message":"Internal error."}

kakopappa commented 1 year ago

Hi @Geromatic

I have fixed the "Internal error."

curl --location --request GET 'https://api.sinric.pro/api/v1/auth/refresh_token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Authorization: Bearer xxxxxxxx' \
--data-urlencode 'refreshToken=xxx'

Response:

{
    "success": true,
    "accessToken": "xxxxx",
    "refreshToken": "xxxx"
}

We will like to know what are you working on!

Geromatic commented 1 year ago

Home automation system + can you update the api documentation to reflect the change

also it works now