pbrunier / node-red-contrib-dyson-purelink

This Node RED module can control dyson purifier (tested with dyson hot&cool pure link)
Other
11 stars 4 forks source link

Can't connect (authenticate to get otp failure) #72

Closed sebastienvermeille closed 1 year ago

sebastienvermeille commented 1 year ago

Describe the bug Can't use the extension on latest nodered version.

When I click "authenticate to get otp" nodered logs print:

"AxiosError: Request failed with status code 400"

(Email and password are valid, country code too)

And I opened the dyson app.

Any idea what can be the root cause ?

sebastienvermeille commented 1 year ago

@pbrunier do you have any idea ? I may give a hand eventually but I am not really sure where to start looking into

pbrunier commented 1 year ago

Hi @sebastienvermeille, 400 probably has to do something with the country code. Are you sure, you use CH instead of ch (or something else)?

sebastienvermeille commented 1 year ago

Hi @pbrunier with CH I get: 400 if the dyson app is open

and 401 if not:

"AxiosError: Request failed with status code 401"

Is there something I can debug on my own eventually ?

pbrunier commented 1 year ago

@sebastienvermeille

Debugging isn't really easy ATM. I will build some user friendly debugging features in the future. I just did some replaying of the node's functionality using a REST client ( https://addons.mozilla.org/nl/firefox/addon/rested/ )

The following calls exactly follow the way the node connects to the Dyson API. Ah well...at least the first two steps. The second step requests the OTP which is emailed to you.

The first step gives you the ability to see if your account is existing and activated: image URL: https://appapi.cp.dyson.com//v3/userregistration/email/userstatus?&country=CH User-Agent: Dalvik/2.1.0 (Linux; U; Android 6.0; Android SDK built for x86_64 Build/MASTER)

The second step is used to request the OTP via email: image URL: https://appapi.cp.dyson.com/v3/userregistration/email/auth?culture=en-US&country=CH User-Agent: The same.

Using CH for me, gives me a German email. image

sebastienvermeille commented 1 year ago

@pbrunier thank you very much for the whole doc it's really appreciated!

For some reason, I played a bit with these queries and I got some 403 answers.

Then: I logged out and back into the dyson app (from my smartphone)

Retried the queries -> it worked -> retried the node-red plugin -> it worked!

works like a charm now can't really say why but well it's great :+1: Thank you for your assistance and these queries it's very useful.