howanghk / homebridge-ewelink

Homebridge plugin to control Sonoff relays with OEM firmware
MIT License
81 stars 46 forks source link

[Question] Example of the login data object #62

Closed PatrikTheDev closed 4 years ago

PatrikTheDev commented 4 years ago

Hi! I am making my own app that uses the ewelink API. I looked at the login and I can't figure out how to log in. I have copied all the data over but it's giving me this response: "{\"error\":406,\"msg\":\"{\\\"oauth_authorise_sign\\\":\\\"params is incomplete\\\"}\"}"

Any ideas? The JSON I am sending is this: {"password":"myPassword","os":"iOS","romVersion":"11.1.2","appVersion":"3.5.3","model":"iPhone10,6","ts":"1574622474","email":"myEmail@gmail.com","version":"6","imei":"9F8B8FAC-FAF3-49FE-A9C4-2C294898D835","appId":"oeVkj2lYFGnJu5XUtWisfW4utiN4u9Mq","nonce":"CFA737D9-4E2A-42A7-8FC7-70731949A865"}

howanghk commented 4 years ago

Hi @Patrik-svobodik, you will need to sign the login request and send the signature in an http header.

Please refer to the code in index.js function login() https://github.com/howanghk/homebridge-ewelink/blob/e23251c81b0a7fb8b4543e7fd97812dc86b0928c/index.js#L1819-L1827

PatrikTheDev commented 4 years ago

Found the issue. I was using “appId” instead of “appid”. Dammit ITead, keep your naming consistent (talking about “nonce” x “nounce”).