mrlt8 / docker-wyze-bridge

WebRTC/RTSP/RTMP/LL-HLS bridge for Wyze cams in a docker container
GNU Affero General Public License v3.0
2.45k stars 151 forks source link

Web UI credentials not persisting? #1237

Open drewdah opened 4 weeks ago

drewdah commented 4 weeks ago

Describe the bug

Since the update that added the Web UI login, I've opened home assistant many times and found my camera dashboard broken. When I go to the docker wyze bridge option in the sidebar, I'm asked to login with my credentials / API information again, but that authentication seems to be expiring or not persisting through restarts of Home Assistant as I've probably done this 5-6 times in the last week.

Am I missing a setting here or do the login credentials expire after a set time or after a Home Assistant restart?

Environment (if applicable)

mrlt8 commented 4 weeks ago

hmm, you shouldn't need to login if you access the bridge via ingress in the sidebar. Can you post the logs from the bridge when it asks for the credentials?

The default credentials wb_password and api key wb_api should persist by writing them to a file in /addon_configs. Can you check if they exist?

drewdah commented 4 weeks ago

Here's what I see after a fresh restart and then accessing via the sidebar. I logged in prior to the restart and in my configuration I have that login saved in my config in WYZE_EMAIL and WYZE_PASSWORD.

🚀 DOCKER-WYZE-BRIDGE v2.9.4 X86_64

[WyzeBridge] [WARN] Credentials are NOT set
[WyzeBridge] ♻️ Clearing local cache...
[WyzeBridge] 🔍 Could not find local cache for 'auth'
[WyzeBridge] ☁️ Fetching 'auth' from the Wyze API...
 * Serving Flask app 'frontend'
[WyzeBridge] Credentials required to complete login!
[WyzeBridge] Please visit the WebUI to enter your credentials.
 * Debug mode: off
[WyzeBridge] WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
 * Running on all addresses (0.0.0.0)
 * Running on http://127.0.0.1:5000
 * Running on http://172.30.33.5:5000
[WyzeBridge] Press CTRL+C to quit
drewdah commented 4 weeks ago

I also checked the addon_configs folder and the only thing I see is a wb_api file and a www folder

mrlt8 commented 4 weeks ago

hmm, do you have FRESH_DATA set to true?

drewdah commented 4 weeks ago

I do have Pull Fresh Data From Wyze API checked yes, I can't remember why. I think I was trying to fix stale thumbnails.

Is that causing it to not store the auth?

mrlt8 commented 4 weeks ago

Yes, that will clear out all the cached data from the api including the access token and refresh token.

Unfortunately, the key and id are now required to complete the login after the recent api changes.

You can add the API Key and ID to the config to have the bridge auto-login to avoid having to do so in the future.

Menz01 commented 2 weeks ago

i dont want to open a new ticket (unless i should) for a very similar but not exactly the same issue...

Every few days or so (not sure of the exact timing) i will open my HA dashboard and my wyze cameras are gone. i open the docker wyze bride and logon and i see that the API has changed, so all the RTSP addresses are changed as well. so i now have to recopy the new RTSP addresses and update them in frigate, and then my cameras are back. but this will only last a few days.

did i do something wrong in a config or something?

mrlt8 commented 2 weeks ago

That is strange. Can you post your setting?

You may also want to check /addon_configs/<docker_wyze_bridge>/ to see if there is a wb_api file in there.

Menz01 commented 2 weeks ago

That is strange. Can you post your setting?

You may also want to check /addon_configs/<docker_wyze_bridge>/ to see if there is a wb_api file in there.

here is my compose file that was scrubbed of personal info https://pastecode.io/s/yia8tvev

mrlt8 commented 2 weeks ago

@Menz01 If you're using docker compose, you'll either need to volume mount the tokens directory

    volumes:
      - ${PWD}/dwb:/tokens

or manually set WB_API

    environment:
    ...
      - WB_API=myCustomKey123
Menz01 commented 2 weeks ago

ok @mrlt8 now i am confused.... if i do the environment route do i still have to put my API ID and API Key in the docker compose? same question applies if i go the volumes route?

mrlt8 commented 2 weeks ago

yes, you would just have to add - WB_API=myCustomKey123 anywhere under environment

Menz01 commented 2 weeks ago

i am sorry but i am not understanding... is there any way you could use my current compose as an example as i feel like it will be in there twice the way i am understanding it

mrlt8 commented 2 weeks ago

something like this:

wyze-bridge:
    container_name: wyze-bridge
    restart: unless-stopped
    image: ghcr.io/mrlt8/docker-wyze-bridge:latest
    ports:
      - 1935:1935 # RTMP
      - 8554:8554 # RTSP
      - 8888:8888 # HLS
      - 8889:8889 #WebRTC
      - 8189:8189/udp # WebRTC/ICE
      - 5000:5000 # WEB-UI
    environment:
      # [REQUIRED] Fill the following two lines:
      - WYZE_EMAIL=<my_email_address>
      - WYZE_PASSWORD=<my_Password>
      # [OPTIONAL] IP Address of the host to enable WebRTC e.g.,:
      - WB_IP=192.168.0.206
      # [OPTIONAL] Wyze API credentials:
      - API_ID=<my_api_id>
      - API_KEY=<my_api_key>
      - ENABLE_AUDIO=True
      - SNAPSHOT=RTSP30
      - WB_API=myCustomKey123
Menz01 commented 2 weeks ago

ok... thank you so much for the example.