gigaset-elements-proxy icon indicating copy to clipboard operation
gigaset-elements-proxy copied to clipboard

Problem with authorizing

Open swissmaster1 opened this issue 5 years ago • 27 comments
trafficstars

Hi Is this still working properly? I get this error in the log file: {"error": {"message": "Unauthorized", "code": 401, "type": "Http401"}}

But when I copy paste the login data from my default.yaml to https://my.gigaset-elements.com I can login on the page. Did Siemens Gigaset maybe change something?

swissmaster1 avatar Apr 13 '20 18:04 swissmaster1

It still works on my setup.

  • is it your first install or it did stop working ?
  • do you have some quotes ' in you password ?

ycardon avatar Apr 14 '20 15:04 ycardon

I've looked closely in my logs, I do sometimes have the same message

[Tue Apr 14 2020 17:18:15] [ERROR]  check events | gigaset response:{"error": {"message": "Unauthorized", "code": 401, "type": "Http401"}}
[Tue Apr 14 2020 17:18:15] [INFO]   authorize on gigaset cloud api : starting
[Tue Apr 14 2020 17:18:15] [INFO]   authorize on gigaset cloud api : done

But it is followed by a successful reconnection: the code is handling these connections problems and perform reconnect. It happen sometimes that the current connexion gets invalid, I've got no clue why it happens.

If it's the same for you (and everything is working), you can ignore the message or try to lower the re-auth interval.

# re-authentication interval in minutes
auth_interval: 10

ycardon avatar Apr 14 '20 16:04 ycardon

It still works on my setup.

  • is it your first install or it did stop working ?
  • do you have some quotes ' in you password ?

Yes it is my first install. And I don't have quotes in my password, only normal letters.

swissmaster1 avatar Apr 15 '20 15:04 swissmaster1

This is what the log says: [ERROR] check events | gigaset response:{"error": {"message": "Unauthorized", "code": 401, "type": "Http401"}} [INFO] authorize on gigaset cloud api : starting [INFO] authorize on gigaset cloud api : done [ERROR] check events | unexpected error: TypeError: Cannot read property 'reverse' of undefined

On what port are the requests made? Could that be a problem of port forwarding may be?

swissmaster1 avatar Apr 15 '20 17:04 swissmaster1

Sorry for the lag in the answers.

Some questions about your setup:

  • do you use gigaset-proxy it as an Hassio addon or as a plain node application ?
  • in the second option, what version of node do you use ? can you upgrade ? mine is v13.12
  • do you have prior messages in the log ? normal starting messages should be
[Thu Apr 16 2020 23:11:15] [INFO]   gigaset-element-proxy v2.2.6 is starting
[Thu Apr 16 2020 23:11:15] [INFO]   authorize on gigaset cloud api : starting
[Thu Apr 16 2020 23:11:15] [INFO]   mqtt connected
[Thu Apr 16 2020 23:11:16] [INFO]   authorize on gigaset cloud api : done
[Thu Apr 16 2020 23:11:16] [INFO]   server listening on http://localhost:8094

ycardon avatar Apr 16 '20 21:04 ycardon

These are the URLs that are requested, they are https requests (port 443) https://github.com/ycardon/gigaset-elements-proxy/blob/3b30e3077ff3c05da6fa9e1692d076c44f32f662/src/gigaset.ts#L6-L13

There is a manual way to debug connectivity, you can try to curl the URLs from your server as @ginkel and I did here

ycardon avatar Apr 16 '20 21:04 ycardon

Last thing: I've pushed some changes 2 days ago on this repo, please git pull && npm run build to make sure you have the latest version.

ycardon avatar Apr 16 '20 22:04 ycardon

Hi ycardon Thanks for answer. I'm using it as a docker image (tgbyte-gigaset-elements-proxy). For this reason I cant git pull && npm run build (or to tell the truth I dont have an idea how to do it.)

This are the prior messages in the log:

[Sat Apr 18 2020 20:56:24] [ERROR]  check events | gigaset response:{"error": {"message": "Unauthorized", "code": 401, "type": "Http401"}}
[Sat Apr 18 2020 20:56:24] [INFO]   authorize on gigaset cloud api : starting 
[Sat Apr 18 2020 20:56:24] [INFO]   authorize on gigaset cloud api : done
[Sat Apr 18 2020 20:56:44] [INFO]   gigaset-element-proxy v2.2.2 is starting
[Sat Apr 18 2020 20:56:44] [INFO]   authorize on gigaset cloud api : starting
[Sat Apr 18 2020 20:56:44] [INFO]   mqtt connected
[Sat Apr 18 2020 20:56:45] [INFO]   authorize on gigaset cloud api : done
[Sat Apr 18 2020 20:56:45] [INFO]   server listening on http://localhost:3000
[Sat Apr 18 2020 20:56:45] [ERROR]  sensor actual status | unexpected error: TypeError: Cannot read property 'sensors' of undefined

swissmaster1 avatar Apr 18 '20 21:04 swissmaster1

Woa nice, someone (it seems to be @ginkel) has posted a docker image !

Well, the docker image is a little outdated (2 months ago) and I will have trouble to help you as I don't know how the image is created. Maybe @ginkel can PR his Dockerfile.

Otherwise, I also maintain a Dockerfile in here but it's specialised for a Hass.io environment.

ycardon avatar Apr 19 '20 13:04 ycardon

The Docker image build is somewhat proprietary due to the way I am building the image in GitLab CI to build a multiarch image (that also supports arm, which I need to deploy on a Raspberry Pi).

I can certainly contribute the Dockerfile, though.

ginkel avatar Apr 19 '20 22:04 ginkel

That would be nice! I'll try that.

swissmaster1 avatar Apr 20 '20 15:04 swissmaster1

Hi ycardon Thanks for answer. I'm using it as a docker image (tgbyte-gigaset-elements-proxy). For this reason I cant git pull && npm run build (or to tell the truth I dont have an idea how to do it.)

What platform are you running on ? A RPi with Raspbian or more generally a linux environment ?

If so, instead of using a docker image, you can go through the options 2 or 3 of the README.md to install the project.

ycardon avatar Apr 21 '20 10:04 ycardon

The Docker image build is somewhat proprietary due to the way I am building the image in GitLab CI to build a multiarch image (that also supports arm, which I need to deploy on a Raspberry Pi).

I can certainly contribute the Dockerfile, though.

Juste wondering: @ginkel did you documented the way to launch your Docker image ? Maybe @swissmaster1 did not correctly referenced his configuration file and is using a default config (without his credentials) inside the image.

ycardon avatar Apr 21 '20 10:04 ycardon

I am deploying though Ansible, but with a very similar syntax to Docker Compose.

- name: deploy gigaset-elements-proxy container
  include_role:
    name: docker/container
  vars:
    docker:
      image: tgbyte/gigaset-elements-proxy
      name: gigaset-elements-proxy
      init: yes
      memory: 128MB
      networks:
        - bridge
        - ha
        - mqtt
        - web
      state: "{{ docker_container_state }}"
      volumes:
        - /srv/gigaset-elements-proxy/config:/config

ginkel avatar Apr 21 '20 10:04 ginkel

What platform are you running on ?

I run it on my Synology Diskstation (Unix) with Intel CPU.

Maybe @swissmaster1 did not correctly referenced his configuration file and is using a default config (without his credentials) inside the image.

I tested it and I‘m sure it‘s working with my configuration file and not default.

swissmaster1 avatar Apr 21 '20 13:04 swissmaster1

Raspberry Pi / Raspbian

Regarding config: You need to have the default.yaml file mounted at /config/default.yaml.

Just another thought: IIRC the Gigaset Elements API is picky about special characters in the password. Try one that contains only numbers and plain letters.

ginkel avatar Apr 21 '20 13:04 ginkel

I thought docker images run on any plattform. Isn‘t that correct?

swissmaster1 avatar Apr 21 '20 13:04 swissmaster1

I thought docker images run on any plattform. Isn‘t that correct?

Nope. tgbyte/gigaset-elements-proxy is a so-called multiarch image that supports amd64 and armv7, though.

ginkel avatar Apr 21 '20 13:04 ginkel

Oh so no chance to run that on my Synology. Thanks guys for answers.

swissmaster1 avatar Apr 21 '20 13:04 swissmaster1

Oh so no chance to run that on my Synology. Thanks guys for answers.

No, amd64 is the instruction set supported by most modern Intel CPUs. ;-)

ginkel avatar Apr 21 '20 13:04 ginkel

But why does it run generally (only authetification error) and doesn‘t give me a runtime error as soon as I start it when my CPU doesn‘t support the instruction set?

swissmaster1 avatar Apr 21 '20 13:04 swissmaster1

Your CPU does support the amd64 instruction set.

ginkel avatar Apr 21 '20 13:04 ginkel

Hmm, now I do not understand anything. When the docker image supports amd64 and my CPU as well, then it should run properly, not?

swissmaster1 avatar Apr 21 '20 13:04 swissmaster1

Well, yes and no. The software runs, but it is getting an authentication error from the GE API.

ginkel avatar Apr 21 '20 13:04 ginkel

And the reason for that is the hardware?

swissmaster1 avatar Apr 21 '20 13:04 swissmaster1

Nope. ;-) You need to figure out why your authentication request is rejected by the server.

ginkel avatar Apr 21 '20 13:04 ginkel

Alright! Now I understood. I think there is something with the ports inside docker. I only assigned port 3000 coming from outside docker to go on port 3000 inside docker.

swissmaster1 avatar Apr 21 '20 13:04 swissmaster1