cnorick / ha-auto-guest-login

https://nathanorick.com/ha-automatic-guest-login
MIT License
41 stars 6 forks source link

Docker Install - No Redirection #27

Open Torrax opened 9 months ago

Torrax commented 9 months ago

I saw you whipped this up a couple years back and have been meaning to set up a webserver and run your code. I recently looked into it again and saw you have a full Docker container and Addon for HA now! Amazing!

I'm currently running all of my HA and all of my different Addons in docker containers on a ubuntu system. I've been trying to get this working as a docker container as that's my only way to set it up however I cant seem to get it to redirect. I keep getting the following error:

404: Not Found
   ^
SyntaxError: Unexpected token : in JSON at position 3
    at JSON.parse (<anonymous>)
    at Response.json (file:///app/node_modules/node-fetch/src/body.js:147:15)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async getFlowId (file:///app/server.js:31:11)
    at async getCode (file:///app/server.js:35:18)
    at async getRedirectUri (file:///app/server.js:61:14)
    at async file:///app/server.js:73:12
Example app listening at http://localhost:4077

Error 404 making me think its having an issue with reaching the address? I have tried to ping the URL from the docker compose below from inside the docker container and it is able to reach it.

Docker Compose:

  ha-auto-guest-login:
    image: norick/ha-auto-guest-login:main
    container_name: ha-auto-guest-login
    port: 4077:80
    environment:
      - CLIENTID=http://192.168.86.200:8123/
      - URL=http://192.168.86.200:8123/
      - DASH=lovelace
      - USER=Guest
      - PASS=password
    restart: unless-stopped

I have tried sending the Post requests manually from a client computer on the network and it looks like everything is going through properly.

Request Body: {"client_id":"http://192.168.86.200:8123","handler":["homeassistant",null],"redirect_uri":"http://192.168.86.200:8123?auth_callback=1"}

Response Body:

{
    "type": "form",
    "flow_id": "ca9c5a54e9e9f63b3d80c69683ebc5fb",
    "handler": [
        "homeassistant",
        null
    ],
    "step_id": "init",
    "data_schema": [
        {
            "type": "string",
            "name": "username",
            "required": true
        },
        {
            "type": "string",
            "name": "password",
            "required": true
        }
    ],
    "errors": {},
    "description_placeholders": null,
    "last_step": null,
    "preview": null
}

Any ideas where it might be getting stuck?

JoeTN commented 2 months ago

Did you ever solve this ? Having the same error.