jfarmer08 / homebridge-wyze-smart-home

Wyze Smart Home plugin for Homebridge.
MIT License
93 stars 14 forks source link

Refresh Token #229

Closed dallasjanssen closed 4 months ago

dallasjanssen commented 4 months ago

Describe The Bug: Randomly a few weeks ago my homebridge was lagging, when I checked the logs I saw Wyze was failing endlessly. I disabled it and due to a busy schedule didn’t revist until this week. Updated to the latest version and problem persists. Got a new API key and removed the config and re-setup. Issue persists.

To Reproduce: Enable plugin and start homebridge service.

Expected behavior: Login and fetch devices.

Logs: [2/26/2024, 10:02:20 PM] [Wyze] Wyze API Error (2002): 'RefreshTokenError' [2/26/2024, 10:02:20 PM] [Wyze] Error getting devices: Error: Refresh Token could not be used to get a new access token. Error: Wyze API Error (2002) - RefreshTokenError [2/26/2024, 10:03:20 PM] [Wyze] Wyze API Error (2001): 'access token is error' [2/26/2024, 10:03:21 PM] [Wyze] Wyze API Error (2002): 'RefreshTokenError' [2/26/2024, 10:03:21 PM] [Wyze] Error getting devices: Error: Refresh Token could not be used to get a new access token. Error: Wyze API Error (2002) - RefreshTokenError

Plugin Config:

"name": "Wyze", "username": "(email)", "password": "(pw)", "keyId": "(key)", "apiKey": "(key)", "refreshInterval": 60000, "hms": true, "showAdvancedOptions": true, "apiLogEnabled": false, "pluginLoggingEnabled": false, "lowBatteryPercentage": 30, "excludeMacAddress": false, "excludedeviceType": true, "filterDeviceTypeList": [ "Camera" ], "platform": "WyzeSmartHome"

Environment:

jfarmer08 commented 4 months ago

I have seen this, you need to delete the stored access token. You can find it in the persist directory for homebridge.

ceedveed commented 4 months ago

persist directory

where is this for a windows install please?

EDIT: Found it at "C:\Users\yourusername\.homebridge\persist"

dallasjanssen commented 4 months ago

I have cleared my whole persistent volume and the error persists. Is there any other troubleshooting you would recommend?

On Tue, Feb 27, 2024 at 1:40 PM Farmer @.***> wrote:

I have seen this, you need to delete the stored access token. You can find it in the persist directory for homebridge.

— Reply to this email directly, view it on GitHub https://github.com/jfarmer08/homebridge-wyze-smart-home/issues/229#issuecomment-1967466828, or unsubscribe https://github.com/notifications/unsubscribe-auth/AXCS5TZQRXQPPNSFJOI67JTYVYZBZAVCNFSM6AAAAABD3L5DM6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRXGQ3DMOBSHA . You are receiving this because you authored the thread.Message ID: @.***>

jfarmer08 commented 4 months ago

Can you turn logging on? That might help give me more ideas. Also does your API Key or KEY Id have any special characters?

ceedveed commented 4 months ago

I have cleared my whole persistent volume and the error persists. Is there any other troubleshooting you would recommend?

For me I had to:

My API key and Key ID did not change. I don't know why I was getting the same errors as you suddenly. But my steps above fixed it.

dallasjanssen commented 4 months ago

My key id does have special characters, it is broken up my dashes.

Here is the plugin logs.

[2/27/2024, 8:36:15 PM] [Wyze] Restarting child bridge... [2/27/2024, 8:36:15 PM] Got SIGTERM, shutting down child bridge process... [2/27/2024, 8:36:20 PM] [Wyze] Child bridge process ended [2/27/2024, 8:36:20 PM] [Wyze] Process Ended. Code: 143, Signal: null [2/27/2024, 8:36:27 PM] [Wyze] Restarting Process... [2/27/2024, 8:36:29 PM] [Wyze] Launched child bridge with PID 1938 [2/27/2024, 8:36:29 PM] Registering platform 'homebridge-wyze-smart-home.WyzeSmartHome' [2/27/2024, 8:36:29 PM] [Wyze] Loaded homebridge-wyze-smart-home v0.5.45 child bridge successfully [2/27/2024, 8:36:29 PM] Loaded 0 cached accessories from cachedAccessories.0E6B23AC20A7. [2/27/2024, 8:36:29 PM] [Wyze] Refreshing devices... [2/27/2024, 8:36:29 PM] Homebridge v1.7.0 (HAP v0.11.1) (Wyze) is running on port 44650. [2/27/2024, 8:36:29 PM] [Wyze] Performing request: {"method":"POST","url":"app/v2/home_page/get_object_list","data":{"access_token":"lvtx./4vNpPQz5Y2iobwbYbtHykIybR0kmJPHNw87WQQaUV1C+z+d/KcNuvagbEUcGBPmedcA5BOQdWDA5JIHXkkD19rbffE66yEUSuVzmcGtAcorgL1AtTINYuqffdLUhePCWibSkX0zkhou9L8jjvzPLRD5sz0L38d4Nn69Oo7YK1Ljsc4cbg2r/5l7CIhFjjgovD5iHA==","app_name":"com.hualai.WyzeCam","app_ver":"wyze_developer_api","app_version":"wyze_developer_api","phone_id":"wyze_developer_api","phone_system_type":"1","sc":"wyze_developer_api","sv":"wyze_developer_api","ts":1709087789980},"baseURL":" https://api.wyzecam.com"} [2/27/2024, 8:36:30 PM] [Wyze] API response PerformRequest: {"url":"app/v2/home_page/get_object_list","status":200,"data":{"code":"2001","msg":"access token is error","traceId":"b9523e22eda82b30ff47f951637f2529","data":{}},"headers":{"date":"Wed, 28 Feb 2024 02:36:30 GMT","content-type":"application/json","content-length":"100","connection":"close","x-ratelimit-remaining":"298","x-ratelimit-reset-by":"Wed Feb 28 02:38:52 GMT 2024","access-control-allow-origin":"","access-control-allow-methods":"POST","access-control-allow-headers":"token","access-control-max-age":"1800","vary":"Origin, Access-Control-Request-Method, Access-Control-Request-Headers"}} [2/27/2024, 8:36:30 PM] [Wyze] API rate limit remaining: 298. Expires in 141062ms [2/27/2024, 8:36:30 PM] [Wyze] Wyze API Error (2001): 'access token is error' [2/27/2024, 8:36:30 PM] [Wyze] Performing request: {"method":"POST","url":"app/user/refresh_token","data":{"access_token":"","app_name":"com.hualai.WyzeCam","app_ver":"wyze_developer_api","app_version":"wyze_developer_api","phone_id":"wyze_developer_api","phone_system_type":"1","sc":"wyze_developer_api","sv":"wyze_developer_api","ts":1709087790942,"refresh_token":"lvtx.1QAi1s8S1Av+O9oxO5R39plzHOw+uK2AqWx2tovuRaPfp8KcX2EdvmIt6urpXD66WKX8SluYGY9jvTpr5e8jUhAmnRKNZfAFygetqkbTMpv8U8BoMSwWlDuL8RYENHoVhhcFRvJ6tpgJSMkLABJGOfnR9+nMTACAJzw+2qSEXiTnVJaZZrC3++cuj0kWQ6dHdpgfuA=="},"baseURL":" https://api.wyzecam.com"} [2/27/2024, 8:36:31 PM] [Wyze] API response PerformRequest: {"url":"app/user/refresh_token","status":200,"data":{"ts":1709087791334,"code":"2002","msg":"RefreshTokenError","data":{}},"headers":{"date":"Wed, 28 Feb 2024 02:36:31 GMT","content-type":"application/json; charset=utf-8","content-length":"70","connection":"close","x-ratelimit-remaining":"298","x-ratelimit-reset-by":"Wed Feb 28 02:38:54 GMT 2024","cache-control":"no-cache","pragma":"no-cache","expires":"-1","server":"Microsoft-IIS/8.5","access-control-allow-headers":"Origin, X-Requested-With, Content-Type, Cache-Control, Accept, authorization, content-type","access-control-allow-methods":"POST,GET,OPTIONS","access-control-allow-origin":"","x-aspnet-version":"4.0.30319","x-powered-by":" ASP.NET"}} [2/27/2024, 8:36:31 PM] [Wyze] API rate limit remaining: 298. Expires in 142566ms [2/27/2024, 8:36:31 PM] [Wyze] Wyze API Error (2002): 'RefreshTokenError' [2/27/2024, 8:36:31 PM] [Wyze] Error getting devices: Error: Refresh Token could not be used to get a new access token. Error: Wyze API Error (2002) - RefreshTokenError

On Tue, Feb 27, 2024 at 8:07 PM Farmer @.***> wrote:

Can you turn logging on? That might help give me more ideas. Also does your API Key or KEY Id have any special characters?

— Reply to this email directly, view it on GitHub https://github.com/jfarmer08/homebridge-wyze-smart-home/issues/229#issuecomment-1968057322, or unsubscribe https://github.com/notifications/unsubscribe-auth/AXCS5T73SVXXRQ32ORLUTSDYV2GOBAVCNFSM6AAAAABD3L5DM6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRYGA2TOMZSGI . You are receiving this because you authored the thread.Message ID: @.***>

dallasjanssen commented 4 months ago

This did it!

I tried a few times and also deleted and got a new key and ID but I am up and running!! Thanks for the help. This can be closed!

On Tue, Feb 27, 2024 at 8:15 PM ceedveed @.***> wrote:

I have cleared my whole persistent volume and the error persists. Is there any other troubleshooting you would recommend?

For me I had to:

  • delete stored token in the persist folder (has wyze in the file name)
  • reset password
  • enter new password in wyze plugin

My API key and Key ID did not change. I don't know why I was getting the same errors as you suddenly. But my steps above fixed it.

— Reply to this email directly, view it on GitHub https://github.com/jfarmer08/homebridge-wyze-smart-home/issues/229#issuecomment-1968064408, or unsubscribe https://github.com/notifications/unsubscribe-auth/AXCS5T36WQXXSMCJEEKJLDLYV2HNNAVCNFSM6AAAAABD3L5DM6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRYGA3DINBQHA . You are receiving this because you authored the thread.Message ID: @.***>

shanekelly55 commented 4 months ago

Hey Team,

Getting this too. I reset my password but still getting some error. Where in Homebridge do I delete everything in the persist folder? Sorry, a bit of a newb here.

EDIT: even newbs can Google. It's fixed now. Thanks Team.

dallasjanssen commented 4 months ago

What are you running homebridge on?

On Tue, Feb 27, 2024 at 9:40 PM shanekelly55 @.***> wrote:

Hey Team,

Getting this too. I reset my password but still getting some error. Where in Homebridge do I delete everything in the persist folder? Sorry, a bit of a newb here.

— Reply to this email directly, view it on GitHub https://github.com/jfarmer08/homebridge-wyze-smart-home/issues/229#issuecomment-1968158222, or unsubscribe https://github.com/notifications/unsubscribe-auth/AXCS5T3NNRKCAW5N7NWXIA3YV2RK7AVCNFSM6AAAAABD3L5DM6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRYGE2TQMRSGI . You are receiving this because you authored the thread.Message ID: @.***>

shanekelly55 commented 4 months ago

It is a raspberry pi so I assume Ubuntu.

carTloyal123 commented 4 months ago

Looks like this is resolved, thanks everyone!

dapostman commented 4 months ago

I think this still needs to be open. Same error continues here with same actions taken. Only difference is running on macOS.

jfarmer08 commented 4 months ago

Maybe some logs would be helpful

Thanks Allen :)

On Sun, Mar 3, 2024 at 8:13 PM dapostman @.***> wrote:

I think this still needs to be open. Same error continues here with same actions taken. Only difference is running on macOS.

— Reply to this email directly, view it on GitHub https://github.com/jfarmer08/homebridge-wyze-smart-home/issues/229#issuecomment-1975532795, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEKHFB7VJ4CSFHJJHWMYPTLYWPKETAVCNFSM6AAAAABD3L5DM6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNZVGUZTENZZGU . You are receiving this because you commented.Message ID: @.***>

csytsma commented 3 months ago

Posting my process, in case it helps anyone else. I'm running Homebridge on a Synology DS218+. Homebridge: v1.6.0 Wyze Plugin: homebridge-wyze-smart-home v0.5.46

My sequence, which worked in the end:

Booted up fine with no more errors.

KyleStilkey commented 2 months ago

Posting my process, in case it helps anyone else. I'm running Homebridge on a Synology DS218+. Homebridge: v1.6.0 Wyze Plugin: homebridge-wyze-smart-home v0.5.46

My sequence, which worked in the end:

  • Reset Wyze password on their site
  • Create new Wyze keys on their site
  • Entered new password and keys in Homebridge
  • NOTE: this didn't fix the problem, same errors after restart
  • Delete the 2 wyze-****.json files in /var/packages/homebridge/shares/homebridge/persist

    • open Terminal, cd to persist folder, rm wyze-****.json
  • Open wyze plugin in Homebridge, confirm password and keys are still there, Save plugin
  • Restart Homebridge

Booted up fine with no more errors.

Tried this but says the directory packages doesn't exist. Not sure what the command is to see the directory listings so I can find these files and remove them.

Figured it out it was the layout for a raspberry pi is different.

So I had some issues going into folders even listed so I had to enter 1 folder at a time but it was easy once I figured it out.

The commands are cd .. to go back and cd (folder name) to go into it. I also used ls -a to list files and folders of the directory. So I went cd var, cd lib, cd homebridge, persist then used the delete command remove and removed all wyze files. I had 3.

Deleted them restarted and now I'm back up and running.

stevejones-softwaredev commented 2 months ago

I believe that Wyze recently changed their refresh token format from an lvtx.XXX format to a JWT format; I was seeing similar auth issues when using refresh token to authenticate. Generating a new refresh token and using that resolved problems I was having with my own homebrew Wyze-based app

kaltechlin35 commented 2 months ago

Posting my process, in case it helps anyone else. I'm running Homebridge on a Synology DS218+. Homebridge: v1.6.0 Wyze Plugin: homebridge-wyze-smart-home v0.5.46

My sequence, which worked in the end:

  • Reset Wyze password on their site
  • Create new Wyze keys on their site
  • Entered new password and keys in Homebridge
  • NOTE: this didn't fix the problem, same errors after restart
  • Delete the 2 wyze-****.json files in /var/packages/homebridge/shares/homebridge/persist

    • open Terminal, cd to persist folder, rm wyze-****.json
  • Open wyze plugin in Homebridge, confirm password and keys are still there, Save plugin
  • Restart Homebridge

Booted up fine with no more errors.

This is exactly what fixed my issue! Thank you very much!