question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Long Lived Access token authentication fails

See original GitHub issue

Hi,

I hope I just have a missing configuration here and not a bug but let’s see.

I use the latest docker version as provided by Causticlab 0.4.0. I’ve configured the following environment variables:

HC_BASEPATH=/hass-config/
HC_API=http://homeassistant:8123/api/                        <- docker interal routing
HC_HASS_WS_API=wss://homeassistant.url.tld/api/    <- browser url
HC_HASS_API_PASSWORD=token

Problem

  1. When trying to observe events by websockets the connection is closed instantly.
  2. When sending commands to HASS, like a restart, it fails.

Ha-configurator logfile:

WARNING:2020-08-22 13:42:33,417:__main__:<urlopen error [Errno 111] Connection refused>

Homeassistant logfile:

[homeassistant.components.http.ban] Login attempt or request with invalid authentication from 10.0.6.36

Question Am I missing a certain configuration or not using the right set here?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
danielperna84commented, Aug 22, 2020

I’m not really familiar with Docker-setups, so I have to refer you to the documentation for that.

I don’t think the version is the issue here. Even though it’s been a while since I’ve worked on this, I believe from 0.3.7 to 0.4.0 no significant changes related to the access token have been made. It was mainly refactoring to make the package for pip and including some JavaScript code which usually was fetched from cloud resources. The Token-stuff has been stable for a long time. So that shouldn’t be the problem in this case.

0reactions
danielperna84commented, Aug 23, 2020

I was also thinking about quotes, I find that the settings.conf file needs quotes around the values since it’s a json structure. Do you use quotes in your systemd configuration? Because I did not in my docker-compose file: I used it as a key value struct HC_HASS_API_PASSWORD=token.token.token

The quotes in the file are required because it’s a JSON file. It would be a syntax error to have a string without quotes. For the env-variable you don’t need quotes, and I don’t have quotes in my unit-file.

Yes, the API is now working and I can do things. On the websocket however I noticed that in the situation where I populated the token via environment variables in docker the password field was also pre-filled.

If the value is not prefilled, the API shouldn’t work as well. If it does, then that’s because you have configured HA to always allow connections from certain locations. The token used to communicate with the API and the prefilled value in the UI are exactly the same. So if one is missing, the other is missing too. So if one is working and the other is not, it must be a policy-thing outside of the scope of the configurator.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Long-lived access token fails sometimes - Configuration
Hi, I have a homemade sensor that uses the Long-lived access token to authenticate towards the api on homeassistant.
Read more >
Exchange short-lived access token for long-lived, not working
I am trying to exchange a short-lived user access token for a ling-lived, but getting an an error (in all.js):.
Read more >
Debugging & Errors - Facebook Login
Expired or invalid access tokens​​ This response is sent when a person logged out of your app or changed their password. The person...
Read more >
Access Token Lifetime - OAuth 2.0 Simplified
The access tokens may last anywhere from the current application session to a couple weeks. When the access token expires, the application will ......
Read more >
Antipattern: Set a long expiration time for OAuth tokens
Setting a long expiration time for an access token and/or refresh token in the OAuthv2 policy leads to accumulation of OAuth tokens and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found