QuickSander / homebridge-mieleathome

Apache License 2.0
37 stars 7 forks source link

Authentication #39

Closed MattB82 closed 3 years ago

MattB82 commented 3 years ago

Hi All,

Wasn't quite sure where to ask but: how do I actually authenticate to use this plugin? I have my client_id and client_secret keys.

I can authenticate via https://www.miele.com/developer/swagger-ui/swagger.html#/ and can use the test requests to see my specific Miele devices but I am instead seeing this detail in my logs:

[Miele@home] Miele API request https://api.mcs3.miele.com/v1/devices?language=en failed with status 401: "Unauthorized". [Miele@home] No valid refresh token known. Token will not be auto refreshed and will expire soon.

I did note that in the notes for the plugin there is an authentication walk through however I didn't see any of this. I should also be clear I'm using HOOBS. Any help much appreciated!

QuickSander commented 3 years ago

If you are using HOOBS you are indeed missing the setup GUI.

Homebridge provides a setup GUI walking you through the process to authenticate it.

You can also manually create the token. In the end it is just a Json file in the homebridge persistent folder. You can check the wiki where it states the manual procedure.

Only thing missing is the correct json format and the file name and location.

MattB82 commented 3 years ago

Thanks @QuickSander!

Which Wiki am I referring to?

QuickSander commented 3 years ago

The wiki on this GitHub page. Check out the navigation bar on the top.

MattB82 commented 3 years ago

Thanks again @QuickSander. I have found myself authenticated and all was good but now I'm getting the following error after needing to setup again. Any ideas what might be causing that?

[Miele@home] Miele API request https://api.mcs3.miele.com/v1/devices?language=en failed with status 401: "Unauthorized".

QuickSander commented 3 years ago

Hi,

In a normal setup in Homebridge, the setup GUI will make sure the config is consistent. I assume you use the config.json options to provide a manually retrieved token.

I cannot see from the log as you only pasted a small portion of it, but I assume the old token remains used. This is because the plugin will continue to keep the token it found on disk and is not checking if you changed the token in the config in the meantime(as that is an advanced option which normally should never be used).

What you can try is to remove the token from the persist directory in Homebridge. This will force the plugin to fallback to trying to use the token as specified by you in the config.json.

The config is a last resort when no token is found on disk.

MattB82 commented 3 years ago

Yep you're right. All fixed up. Cheers @QuickSander !