Brandawg93 / homebridge-nest-cam

View your Nest cams in HomeKit using Homebridge.
https://www.npmjs.com/package/homebridge-nest-cam
GNU General Public License v3.0
211 stars 27 forks source link

[Bug]: refresh token not working, keep throwing 403 error #516

Closed fjiang423 closed 1 year ago

fjiang423 commented 2 years ago

Describe the bug

Problem: plugin keeps complaining 403 error while startup.

I followed wiki to generate new refresh token (through UI and command line), but the plugin still won't be able to authenticate. The generated refresh token seems correct, because copying it to Nest plugin config and it can work flawlessly without problem.

Not sure why nest-cam can't login. The debug log doesn't contain useful information, see below.

Debug Output

[9/26/2022, 12:09:48 AM] [Nest-cam] Initializing Nest-cam platform...
[9/26/2022, 12:09:48 AM] [Nest-cam] Using motionDetection from config: true
[9/26/2022, 12:09:48 AM] [Nest-cam] Using doorbellAlerts from config: true
[9/26/2022, 12:09:48 AM] [Nest-cam] Using doorbellSwitch from config: true
[9/26/2022, 12:09:48 AM] [Nest-cam] Using streamingSwitch from config: true
[9/26/2022, 12:09:48 AM] [Nest-cam] Using chimeSwitch from config: true
[9/26/2022, 12:09:48 AM] [Nest-cam] Using announcementsSwitch from config: true
[9/26/2022, 12:09:48 AM] [Nest-cam] Using audioSwitch from config: true
[9/26/2022, 12:09:48 AM] [Nest-cam] Defaulting structures to []
[9/26/2022, 12:09:48 AM] [Nest-cam] Defaulting cameras to []
[9/26/2022, 12:09:48 AM] [Nest-cam] Configuring accessory Front Door Doorbell
[9/26/2022, 12:09:48 AM] [Nest-cam] Using importantOnly from config: true
[9/26/2022, 12:09:48 AM] [Nest-cam] Creating microphone for Front Door Doorbell.
[9/26/2022, 12:09:48 AM] [Nest-cam] Creating doorbell sensor for Front Door Doorbell.
[9/26/2022, 12:09:48 AM] [Nest-cam] Creating doorbell switch for Front Door Doorbell.
[9/26/2022, 12:09:48 AM] [Nest-cam] Creating switch for Front Door Doorbell Streaming.
[9/26/2022, 12:09:48 AM] [Nest-cam] Creating switch for Front Door Doorbell Chime.
[9/26/2022, 12:09:48 AM] [Nest-cam] Creating switch for Front Door Doorbell Announcements.
[9/26/2022, 12:09:48 AM] [Nest-cam] Creating switch for Front Door Doorbell Audio.
[9/26/2022, 12:09:48 AM] [Nest-cam] Authenticating via Google refresh token.
[9/26/2022, 12:09:58 AM] [Nest-cam] Checking for alerts on Front Door (Doorbell)
[9/26/2022, 12:10:04 AM] [Nest-cam] Error checking alerts: 403

Steps to reproduce

Device Type

synology nas

iOS Version

16.0

Camera Types

Nest Hello

Bug Persistence

Consistently

Last Working Version

No response

Robert91112 commented 1 year ago

I am getting the same errors. When i attempt to re authenticate, i get the following from google:

image

image

Brandawg93 commented 1 year ago

Has anyone tried the old authentication method? Does that still work for anyone else?

https://github.com/Brandawg93/homebridge-nest-cam/wiki/Manual-Authentication#browser-cookies

mapotter99 commented 1 year ago

@Brandawg93 I’m brand new to Homebridge this week, and I have some Nest cams that are a few years old… definitely not the new Google versions.

It may be a separate issue from the OP, but I’m getting the exact same authentication errors as @Robert91112 shown in the pictures above when I try to get the plug-in setup. Has Google broken your authentication?

Brandawg93 commented 1 year ago

@mapotter99 Which authentication method did you use?

fjiang423 commented 1 year ago

Browser cookie method does not work for me too... Get same error

mapotter99 commented 1 year ago

@Brandawg93 Im trying to use the homebridge-config-ui-x method where it says “Click HERE to open the Nest login page.”

eugenet8k commented 1 year ago

@Brandawg93 I just tried the old method (browser cookies) and it also does not work:

[Nest] Auth failed: access token specified in Homebridge configuration rejected
[Nest] Unable to authenticate with Google/Nest.
[Nest] NOTE: Because we couldn't connect to the Nest service, your Nest devices in HomeKit will not be responsive.

It's important to note that the nest_token (access_token) approach works just fine with homebridge-nest plugin, so this might be specific to this homebridge-nest-cam plugin.

jdtoppin commented 1 year ago

New to Homebridge as well.

Same error as @Robert91112 above.

This occurs during the step to get the refresh token and in the homebridge ui page as well.

Edit. Nevermind, I see that you can't use refresh token at all anymore and must use the issue/cookie tokens.

Proper format to get it working was as follows:

{ "googleAuth": { "issueToken": "issue_token_code", "cookies": "cookies_code" }, "options": { "ffmpegCodec": "libx264", "streamQuality": 3, "alertCheckRate": 10, "alertCooldownRate": 180, "alertTypes": [ "Motion", "Sound", "Person", "Package Delivered", "Package Retrieved", "Face", "Zone" ], "importantOnly": true, "motionDetection": false, "streamingSwitch": true, "chimeSwitch": false, "announcementsSwitch": false, "doorbellAlerts": false, "doorbellSwitch": false, "audioSwitch": true }, "platform": "Nest-cam" }

Think the documentation just needs to be updated to not mention the old auth methods such as refresh and nest token, unless you're supposed to combine nest token with the issuetoken/cookie, but in my case, I didn't need to. Would help to include the entire string that should be used in the json.

scramble45 commented 1 year ago

Might be helpful to link this, took me a few to get this working again on my setup: https://github.com/ryanleesmith/homebridge-google-nest#readme

raphus commented 1 year ago

Might be helpful to link this, took me a few to get this working again on my setup: https://github.com/ryanleesmith/homebridge-google-nest#readme

could you please elaborate on how you got this going? what exact parameters did you add to the config? The current config has ""refreshToken" parameter. Did you replace with something like this?

  "googleAuth": {
        "issueToken": "https://accounts.google.com/o/oauth2/iframerpc?action=issueToken...",
        "cookies": "OCAK=TOMPYI3cCPAt...; SID=ogftnk...; HSID=ApXSR...; ...; SIDCC=AN0-TYt...",
        "apiKey": "AIzaS..."
      },

thanks.

Ryamonster10 commented 1 year ago

Is there any current way to authenticate?

jdtoppin commented 1 year ago

Is there any current way to authenticate?

I posted my solution up above. Just need to replace the cookie and issue tokens with your own as per the homebridge Google nest faq that others have linked.

Ultimately, the faq and documentation just need updating.

Brandawg93 commented 1 year ago

This is already documented and does not work according to others: https://github.com/Brandawg93/homebridge-nest-cam/wiki/Manual-Authentication

Google recently introduced a new webpage to view all cameras which also means code for reverse engineering! I just need to find time to look at it.

scramble45 commented 1 year ago

This is already documented and does not work according to others: https://github.com/Brandawg93/homebridge-nest-cam/wiki/Manual-Authentication

Google recently introduced a new webpage to view all cameras which also means code for reverse engineering! I just need to find time to look at it.

Works for me but seems like it expires after some time also had to use chromium for the cookies, think they are formed differently in Firefox... or something, could probably scrape this info with out with chrome headless on a schedule to make it work. Just throwing out ideas.

          {
            "googleAuth": {
                "issueToken": "https://accounts.google.com/o/oauth2/iframerpc?action=issueToken&response_type=token%20id_token&login_hint=[REDACTED]",
                "cookies": "__Secure-3PSID=QAgcMiiuQ1GLOIPJJgC[REDACTED]",
                "apiKey": "AIzaSyAdkSIMNc[REDACTED]"
            },
a-watts commented 1 year ago

I managed to get it to work with my Google Nest Account via below config. I got my issueToken and cookie via the manual browser method. I did this on Homebridge fyi.

    {
        "name": "Nest-cam",
        "googleAuth": {
            "issueToken": "<https://accounts.google.com/o/oauth2/...>",
            "cookies": "<place cookie value here>"
        },
        "options": {
            "ffmpegCodec": "libx264",
            "streamQuality": 3,
            "alertCheckRate": 10,
            "alertCooldownRate": 180,
            "alertTypes": [
                "Motion",
                "Sound",
                "Person",
                "Package Delivered",
                "Package Retrieved",
                "Face",
                "Zone"
            ],
            "importantOnly": true,
            "motionDetection": false,
            "streamingSwitch": true,
            "chimeSwitch": false,
            "announcementsSwitch": false,
            "doorbellAlerts": false,
            "doorbellSwitch": false,
            "audioSwitch": true
        },
        "_bridge": {
            "username": "1E:82:3D:12:31:48",
            "port": 31882
        },
        "platform": "Nest-cam"
    },
askovi commented 1 year ago

For anyone coming here for the auth issue, we published a chrome extension at HOOBS that extracts the issueToken and Cookies values for you automatically. This works for homebridge too. You can find the instructions here: https://plugins.hoobs.org/plugin/homebridge-nest-cam

rbeniers commented 1 year ago

I managed to get it to work with my Google Nest Account via below config. I got my issueToken and cookie via the manual browser method. I did this on Homebridge fyi.

    {
        "name": "Nest-cam",
        "googleAuth": {
            "issueToken": "<https://accounts.google.com/o/oauth2/...>",
            "cookies": "<place cookie value here>"
        },
        "options": {
            "ffmpegCodec": "libx264",
            "streamQuality": 3,
            "alertCheckRate": 10,
            "alertCooldownRate": 180,
            "alertTypes": [
                "Motion",
                "Sound",
                "Person",
                "Package Delivered",
                "Package Retrieved",
                "Face",
                "Zone"
            ],
            "importantOnly": true,
            "motionDetection": false,
            "streamingSwitch": true,
            "chimeSwitch": false,
            "announcementsSwitch": false,
            "doorbellAlerts": false,
            "doorbellSwitch": false,
            "audioSwitch": true
        },
        "_bridge": {
            "username": "1E:82:3D:12:31:48",
            "port": 31882
        },
        "platform": "Nest-cam"
    },

This also worked for me. Just copy this config and add values for the issuetoken and cookies using the HOOBS chrome extension.

lnjustin commented 1 year ago

Google recently introduced a new webpage to view all cameras which also means code for reverse engineering! I just need to find time to look at it.

Guessing this is still an ongoing issue that hasn't been resolved yet. Can't tell if this is the cookie option is a temporary band-aid or a viable long-term solution?

lnjustin commented 1 year ago

Seems to be a temporary fix since my token expired - right? I like this plugin better than the SDM one because it shows the footage for cameras without having to tap on each camera first, but it seems as tho this plugin is having issues staying logged in. At least that's the case for me.... is that everyone else's experience too or is there a workaround I'm not aware of?

stulevine commented 1 year ago

For anyone coming here for the auth issue, we published a chrome extension at HOOBS that extracts the issueToken and Cookies values for you automatically. This works for homebridge too. You can find the instructions here: https://plugins.hoobs.org/plugin/homebridge-nest-cam

@askovi Thank you. This worked perfectly for me to get my Nest Cams back online in Home Bridge. Brilliant!

mapotter99 commented 1 year ago

UPDATE: Scratch that. I got it working. I was including the <> brackets in the token and cookies. They aren't used when you copy your own token and cookies over... just the quotation marks.


I've used the Hoobs extension to copy the token and the cookies into the config file as explained.

Unfortunately, it still isn't working.

I notice the following in the Homebridge log...

[05/01/2023, 10:05:53] Loaded 0 cached accessories from cachedAccessories. [05/01/2023, 10:05:53] [homebridge-nest-cam] Access token acquisition via googleAuth failed (code ERR_INVALID_URL). [05/01/2023, 10:05:53] [homebridge-nest-cam] Unable to retrieve access token.

sidwyn commented 1 year ago

I've done the above, and nest-cam doesn't seem to throw any errors in the console, but I don't see it in Homekit. What gives?

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 3 days