dgreif / homebridge-petsafe-smart-feed

A homebridge plugin for PetSafe Smart Feed
MIT License
14 stars 1 forks source link

Failed to generate token #32

Closed HQuest closed 3 years ago

HQuest commented 3 years ago

Clear installation of this plugin (v1.3.1) under Homebridge v1.3.4. After I enter my email address, I receive the token over email and it fails to link the account with error 422, as below. Logging via the Smart Feed app (iOS) works just fine - although the token email comes from a different host in their domain, "directory.cloud.petsafe.net" instead of "cloud.petsafe.net".

Tried to downgrade to plugin v1.3.0, to no avail.

[7/13/2021, 7:48:43 AM] [Homebridge UI] [homebridge-petsafe-smart-feed] Incoming Request: /token
Getting token for email@address.com with code 946303
[7/13/2021, 7:48:43 AM] [Homebridge UI] [homebridge-petsafe-smart-feed] Failed to generate token
[7/13/2021, 7:48:43 AM] [Homebridge UI] [homebridge-petsafe-smart-feed] HTTPError: Response code 422 (Unprocessable Entity)
    at Request.<anonymous> (/homebridge/node_modules/homebridge-petsafe-smart-feed/node_modules/got/dist/source/as-promise/index.js:117:42)
    at processTicksAndRejections (internal/process/task_queues.js:95:5) {
  code: undefined,
  timings: {
    start: 1626176923579,
    socket: 1626176923580,
    lookup: undefined,
    connect: undefined,
    secureConnect: undefined,
    upload: 1626176923580,
    response: 1626176923601,
    end: 1626176923603,
    error: undefined,
    abort: undefined,
    phases: {
      wait: 1,
      dns: undefined,
      tcp: undefined,
      tls: undefined,
      request: NaN,
      firstByte: 21,
      download: 2,
      total: 24
    }
  }
}
[7/13/2021, 7:48:47 AM] [Homebridge UI] [homebridge-petsafe-smart-feed] Terminating child process...
[7/13/2021, 7:48:47 AM] [Homebridge UI] [homebridge-petsafe-smart-feed] Child process ended

However, via CLI I am able to obtain a token properly:

/homebridge # npx -p homebridge-petsafe-smart-feed petsafe-auth-cli
npx: installed 34 in 4.986s
This CLI will provide you with a token which you can use to configure homebridge-petsafe-smart-feed. Please enter your email address to start the process.
Email: email@address.com
You should now receive an email from PetSafe.  Please enter the code from that email below.
Code: 247242

Successfully logged in to PetSafe. Please use the following line in your homebridge config:

"token": "eyJhbGc(...)Fzuv8"
dgreif commented 3 years ago

@HQuest I can't reproduce this issue. Are you still seeing the problem if you click "Link to new account"? If so, what version of node are you on?

HQuest commented 3 years ago

@dgreif yep, linking a new account. node v14.17.3 - this version came installed with the docker version of homebridge.

I'm also seeing "[PetSafeSmartFeed] HTTPError: Response code 429 (Too Many Requests)" errors at homebridge logs, even at times I don't have the Home app open at any of my devices (such as night time while I'm asleep). Afraid it might blacklist me as other vendors (Honeywell) do.

dgreif commented 3 years ago

@HQuest it looks like there is a new API that they are rolling out (See #34). I'll get the plugin updated some time in the next few weeks, but mines still working fine with the old api for now. If you can get a working token via the cli, that's the best solution for now.

dgreif commented 3 years ago

v2.0.0 is out and uses the new API. You should be able to update your plugin and then generate a new token. Let me know how it goes!