KraigM / homebridge-wink

Wink hub plugin for HomeBridge
54 stars 37 forks source link

Accessing API data directly with just Curl #94

Closed mkanet closed 6 years ago

mkanet commented 6 years ago

Sorry if this isn't directly related to homebridge-wink. I'm posting here out of sheer desperation. I've been looking for a way to access real-time data from my Wink2 connected devices (sensors, etc) via Curl without any additional dependencies.; just curl on Windows command-line (or something similar). I can't find any information on this anywhere; except for the below URL: https://github.com/KraigM/homebridge-wink/wiki/Investigation-of-an-Unofficial-Wink-API

If I use the first example provided in the link above (plugging in my client_id, secret, username, password): curl -H 'Host: api.wink.com' -H 'Accept: */*' --data-binary '{"client_id":"xxxxxx","username":"email address","password":"password","client_secret":"CODE","grant_type":"password"}' --compressed 'https://api.wink.com/oauth2/token'

I keep getting the error:

"{"data":{"error":"unsupported_grant_type"},"errors":["unsupported_grant_type"],"pagination":{},"error":"unsupported_grant_type"}"

I'm really hoping someone with a lot more experience could offer an updated working example to access this info with just curl or something similar on the Windows command-line. Thank so much in advance!

AppleTechy commented 6 years ago

Shortly after I wrote that Wink changed their OAUTH system and how they issued Client ID and Secrets. How did you aquire the Client ID and Secret, did you request it from them? I have found that their Official Client Secret/ID from their Android and IOS apps allowed access to certain CURL requests that were blocked by more recent generated Client Secrets/IDs. I can confirm that it is working for me using their Official app credentials. I don't have access to my old credentials that were generated by them for me, nor the more recent ones, so I cannot confirm for those.

mkanet commented 6 years ago

Thank so much for the quick reply back. I got my Client ID and Secret from developer.wink.com. I have an Android phone and the Wink App. However, I dont know how to access the app client ID and secret. Any help to get this info would be greatly appreciated. michael @mka.net

AppleTechy commented 6 years ago

You can find the android app Client ID/Secret floating around online. I would try using those first. As for finding it yourself its pretty hands-on, you have to intercept the SSL traffic between your phone and Wink’s servers using an app like Charles Proxy or MITM. I believe they are using SSL pinning so you can’t just do it on an IOS device(you would need it to be jailbroken so you can get around the pinning) or on Android you would need a rooted phone.

On Jun 18, 2018, 11:19 AM -0700, MKANET notifications@github.com, wrote:

Thank so much for the quick reply back. I got mine the Client ID and Secret from developer.wink.com. I have an Android phone and the Wink App. However, I dont know how to access the app client ID and secret. Any help to get this info would be greatly appreciated. michael @mka.net — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

mkanet commented 6 years ago

Thanks for the tip! I was able to find them pretty quickly. However, replacing mine with the ones from the app still resulted in the same exact error message. I'm not sure if it's because of the syntax is wrong or what. If you happened to see something that's obviously wrong below, please let me know. Thanks for all your help!

curl -H "Host: api.wink.com" -H "Accept: */*" --data-binary "{"client_id":"xxxxxxxxxxxxxxxxxxxxxxx","username":"mywinkemailaddressusername","password":"mywinkaccountpassword","client_secret":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","grant_type":"mywinkaccountpassword"}" --compressed "https://api.wink.com/oauth2/token"

_{"data":{"error":"unsupported_grant_type"},"errors":["unsupported_grant_type"],"pagination":{},"error":"unsupported_granttype"}

AppleTechy commented 6 years ago

Above you have the grant_type mis set, is that your actual CURL command? I would try a different Client Secret/ID. Also you could take a look at Wink's Official API which will be compatible with the Client Secret/ID that they issued you.

mkanet commented 6 years ago

For grant_type, I put my wink account password. I also tried just "password". Both produced the same error. I'll need to go through the official API documentation.

AppleTechy commented 6 years ago

Did you figure it out? You can reach me on the Slack channel if you want for further info. The grant type should just be left as “password” or whatever the CURL is listed on the wiki page On Jun 18, 2018, 6:56 PM -0700, MKANET notifications@github.com, wrote:

Closed #94. — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

mkanet commented 6 years ago

I haven't figured it out yet. It seems like the errors I'm getting aren't related to the grant type value; although, I'm now using "password" as the value. I really appreciate all your help.

mkanet commented 6 years ago

@AppleTechy how can I reach you on Slack? I have an account/workspace there with the github app installed (and signed in) on Slack.

AppleTechy commented 6 years ago

Have you joined the Homebridge Workplace? If so I am @AppleGeek on it. If not check out the readme file in the Nfarina’s Homebridge repo and it should have a link to request the invite to the workplace On Jun 19, 2018, 9:03 AM -0700, MKANET notifications@github.com, wrote:

@AppleTechy how can I reach you on Slack? I have an account/workspace there with the github app installed (and signed in) on Slack. — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.