homebridge-nest-cam icon indicating copy to clipboard operation
homebridge-nest-cam copied to clipboard

[Bug]: Nest Auth doesn't work with FT accounts

Open no1knows opened this issue 2 years ago • 11 comments

Describe the bug

In connection.ts, NEST_AUTH_URL refers to the non-FT URL regardless of whether "fieldTest": true in the config. This means that Nest Auth does not work for FT accounts:

[5/22/2022, 9:22:54 AM] [Nest-cam] Nest authentication failed (code undefined).
[5/22/2022, 9:22:54 AM] [Nest-cam] Unable to retrieve access token.

I managed to get it working by changing NEST_AUTH_URL = 'https://webapi.camera.home.ft.nest.com/api/v1/login.login_nest'; I also changed Referer: 'https://home.ft.nest.com', both in connection.ts (lines 15 and 238 respectively). Not sure if the change to Referer is necessary,

Would it be possible to make this change to the plugin code so the correct AUTH URL (and Referer URL, if necessary) are chosen depending on whether "fieldTest": true in the config?

Thank you!

Debug Output

[5/22/2022, 9:22:54 AM] [Nest-cam] Nest authentication failed (code undefined).
[5/22/2022, 9:22:54 AM] [Nest-cam] Unable to retrieve access token.

Steps to reproduce

include '"fieldTest": true` and 'nest_token' in the config, and use an FT token.

Device Type

RPi 4

iOS Version

n/a

Camera Types

All

Bug Persistence

Consistently

Last Working Version

No response

no1knows avatar May 22 '22 21:05 no1knows

Thanks for the catch! I've published a new test version (v7.5.1-test.2). You can install it via the UI (Previous Versions). Let me know if this fixes your issue.

Brandawg93 avatar May 28 '22 19:05 Brandawg93

Thanks! I've done that but I still get:

[5/28/2022, 10:20:00 PM] Loaded plugin: [email protected]
...
[5/28/2022, 10:20:02 PM] [Nest-cam] Nest authentication failed (code undefined).
[5/28/2022, 10:20:02 PM] [Nest-cam] Unable to retrieve access token.

Looking at the test.2 code in connection.ts, I don't see any changes to reflect the new FT URL?

no1knows avatar May 28 '22 21:05 no1knows

Ya just noticed that too.. test.3 is now up. Let me know if that works.

Brandawg93 avatar May 28 '22 21:05 Brandawg93

Same issue, and still don't see any changes to NEST_AUTH_URL to refer to the FT URL :)

no1knows avatar May 29 '22 06:05 no1knows

I just realized you are using the old Nest authentication instead of Google :) Whoops. Try test.4 and see if you see changes now.

Brandawg93 avatar Jun 09 '22 19:06 Brandawg93

No joy I'm afraid...

[6/11/2022, 6:17:33 PM] [Nest-cam] Nest authentication failed (code undefined).
[6/11/2022, 6:17:33 PM] [Nest-cam] Unable to retrieve access token.
[6/11/2022, 6:17:42 PM] [Nest-cam] Error checking alerts: 403
Troubleshoot here: https://git.io/Jtxww
[6/11/2022, 6:17:42 PM] [Nest-cam] Error checking alerts: 403
Troubleshoot here: https://git.io/Jtxww

I've checked the token and it's still valid and working with the rudimentary changes I made here: https://github.com/no1knows/homebridge-nest-cam-ft/blob/master/src/nest/connection.ts

no1knows avatar Jun 11 '22 17:06 no1knows

Hm. Not sure what else it could be. You can see the changes in this commit: c885217c27f5838c859c953ea50bf99b9049e580

I just added the ft flag to the old nest auth.

Brandawg93 avatar Jun 16 '22 23:06 Brandawg93

I went ahead and published v7.5.1 with the above changes. Let me know if they still don't work. This version has a few other fixes as well.

Brandawg93 avatar Jun 17 '22 00:06 Brandawg93

Thanks! Still no luck, but I have no idea why looking at your changes (i.e. they LGTM, but I really am no expert):

[6/22/2022, 7:44:44 AM] [Nest-cam] Error checking alerts: 403 Troubleshoot here: https://git.io/Jtxww

Here's my config:

    "nest_token": "[known good token from https://home.ft.nest.com/session]",
    "options": {
        "fieldTest": true,
        "ffmpegCodec": "libx264",
        "streamQuality": 3,
        "alertCheckRate": 10,
        "alertCooldownRate": 180,
        "alertTypes": [
            "Motion",
            "Sound",
            "Person",
            "Package Delivered",
            "Package Retrieved",
            "Face",
            "Zone"
        ],
        "importantOnly": true,
        "motionDetection": true,
        "streamingSwitch": true,
        "chimeSwitch": false,
        "announcementsSwitch": false,
        "doorbellAlerts": true,
        "doorbellSwitch": false,
        "audioSwitch": false
    },
    "platform": "Nest-cam"
}

Is there debug logging I can enable?

no1knows avatar Jun 22 '22 06:06 no1knows

You can enable debug logging in the UI settings.

Brandawg93 avatar Jun 22 '22 14:06 Brandawg93

Thanks. No additional relevant logs are shown. My only changes were to the NEST_AUTH_URL and Referer URL, which I think is all you've changed (albeit in your case depending on whether "fieldTest": true), and yet my fork works. Does my config above LGTY? If so, I'm at a loss.

no1knows avatar Jun 22 '22 20:06 no1knows

I was able to fix this locally with the following changes:

  • src/nest/connection.ts#L223: fix referer to be https://home.ft.nest.com instead of https://home.nest.ft.com
  • src/nest/connection.ts#L222 : Remove default false value for the ft argument to make sure all nest_auth callers specify it
  • src/nest/connection.ts#L255: Pass ft to nest_auth
  • src/index.ts#L335: Pass ft to nest_auth

Sent you https://github.com/Brandawg93/homebridge-nest-cam/pull/512

tronikos avatar Sep 24 '22 07:09 tronikos

I've merged and published v7.5.3. Thanks @tronikos!

If anyone still experiences issues, feel free to reopen this.

Brandawg93 avatar Sep 24 '22 23:09 Brandawg93