Closed quantummobile closed 5 years ago
Same here for docker.
As per ticket #26613 I can't Authorise Withings. I couldn't get this to work on 0.99b1 - 0.99b3
In my configuration.yaml I have the following:
http:
base_url: https://xx.duckdns.org
withings:
client_id: !secret withings_id
client_secret: !secret withings_secret
profiles:
- William
logger:
default: info
logs:
homeassistant.components.withings: critical
When I go to the integrations page and select Withings and then choose my profile/user I am redirected to the authorization API website. I select "Allow this app" After that I can see a very short glimpse of a message coming up on the integration screen and then it goes back to the "Allow this app" Page. If I press the "Allow this app" button for a second time I get
500 Internal Server Error Server got itself in trouble
I am running HASSIO as a native package on a Synology NAS, also using the built in reverse proxy.
This is the log I get:
2019-09-19 07:33:54 ERROR (MainThread) [frontend.js.latest.201909181] http://192.168.1.210:8123/frontend_latest/chunk.43dcfc6e5b8d18714299.js:1007:164 Uncaught TypeError: Cannot read property 'item' of undefined
2019-09-19 07:34:08 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/aiohttp/web_protocol.py", line 418, in start
resp = await task
File "/usr/local/lib/python3.7/site-packages/aiohttp/web_app.py", line 458, in _handle
resp = await handler(request)
File "/usr/local/lib/python3.7/site-packages/aiohttp/web_middlewares.py", line 119, in impl
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/real_ip.py", line 40, in real_ip_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 73, in ban_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 231, in auth_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 128, in handle
result = await result
File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 155, in get
return await super().get(request, flow_id)
File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 78, in get
result = await self._flow_mgr.async_configure(flow_id)
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 89, in async_configure
result = await self._async_handle_step(flow, cur_step["step_id"], user_input)
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 132, in _async_handle_step
result: Dict = await getattr(flow, method)(user_input)
File "/usr/src/homeassistant/homeassistant/components/withings/config_flow.py", line 132, in async_step_finish
return await self._async_create_session(profile, code)
File "/usr/src/homeassistant/homeassistant/components/withings/config_flow.py", line 139, in _async_create_session
credentials = auth_client.get_credentials(code)
File "/usr/local/lib/python3.7/site-packages/nokia/__init__.py", line 86, in get_credentials
client_secret=self.consumer_secret)
File "/usr/local/lib/python3.7/site-packages/requests_oauthlib/oauth2_session.py", line 307, in fetch_token
self._client.parse_request_body_response(r.text, scope=self.scope)
File "/usr/local/lib/python3.7/site-packages/oauthlib/oauth2/rfc6749/clients/base.py", line 421, in parse_request_body_response
self.token = parse_token_response(body, scope=scope)
File "/usr/local/lib/python3.7/site-packages/oauthlib/oauth2/rfc6749/parameters.py", line 431, in parse_token_response
validate_token_parameters(params)
File "/usr/local/lib/python3.7/site-packages/oauthlib/oauth2/rfc6749/parameters.py", line 441, in validate_token_parameters
raise MissingTokenError(description="Missing access token parameter.")
oauthlib.oauth2.rfc6749.errors.MissingTokenError: (missing_token) Missing access token parameter.
2019-09-19 07:34:12 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/aiohttp/web_protocol.py", line 418, in start
resp = await task
File "/usr/local/lib/python3.7/site-packages/aiohttp/web_app.py", line 458, in _handle
resp = await handler(request)
File "/usr/local/lib/python3.7/site-packages/aiohttp/web_middlewares.py", line 119, in impl
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/real_ip.py", line 40, in real_ip_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 73, in ban_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 231, in auth_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 128, in handle
result = await result
File "/usr/src/homeassistant/homeassistant/components/withings/config_flow.py", line 182, in get
flow_id, {const.PROFILE: profile, const.CODE: code}
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 89, in async_configure
result = await self._async_handle_step(flow, cur_step["step_id"], user_input)
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 132, in _async_handle_step
result: Dict = await getattr(flow, method)(user_input)
File "/usr/src/homeassistant/homeassistant/components/withings/config_flow.py", line 132, in async_step_finish
return await self._async_create_session(profile, code)
File "/usr/src/homeassistant/homeassistant/components/withings/config_flow.py", line 139, in _async_create_session
credentials = auth_client.get_credentials(code)
File "/usr/local/lib/python3.7/site-packages/nokia/__init__.py", line 86, in get_credentials
client_secret=self.consumer_secret)
File "/usr/local/lib/python3.7/site-packages/requests_oauthlib/oauth2_session.py", line 307, in fetch_token
self._client.parse_request_body_response(r.text, scope=self.scope)
File "/usr/local/lib/python3.7/site-packages/oauthlib/oauth2/rfc6749/clients/base.py", line 421, in parse_request_body_response
self.token = parse_token_response(body, scope=scope)
File "/usr/local/lib/python3.7/site-packages/oauthlib/oauth2/rfc6749/parameters.py", line 431, in parse_token_response
validate_token_parameters(params)
File "/usr/local/lib/python3.7/site-packages/oauthlib/oauth2/rfc6749/parameters.py", line 441, in validate_token_parameters
raise MissingTokenError(description="Missing access token parameter.")
oauthlib.oauth2.rfc6749.errors.MissingTokenError: (missing_token) Missing access token parameter.
Hey there @vangorra, mind taking a look at this issue as its been labeled with a integration (withings
) you are listed as a codeowner for? Thanks!
I have the same issue - first it failed with invalid call back ID - fixed by adding the nabu casa base URL to config and the Withings API, then a failure to redirect from the auth screen to HA - fixed by not having a space in the profile
Now I am hitting the same wall - first attempt to link bounces you back to the integrations screen, second the 500 server error.
Thu Sep 19 2019 10:04:57 GMT+0100 (British Summer Time)
Error handling request
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/aiohttp/web_protocol.py", line 418, in start
resp = await task
File "/usr/local/lib/python3.7/site-packages/aiohttp/web_app.py", line 458, in _handle
resp = await handler(request)
File "/usr/local/lib/python3.7/site-packages/aiohttp/web_middlewares.py", line 119, in impl
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/real_ip.py", line 40, in real_ip_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 73, in ban_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 231, in auth_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 128, in handle
result = await result
File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 155, in get
return await super().get(request, flow_id)
File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 78, in get
result = await self._flow_mgr.async_configure(flow_id)
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 89, in async_configure
result = await self._async_handle_step(flow, cur_step["step_id"], user_input)
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 132, in _async_handle_step
result: Dict = await getattr(flow, method)(user_input)
File "/usr/src/homeassistant/homeassistant/components/withings/config_flow.py", line 132, in async_step_finish
return await self._async_create_session(profile, code)
File "/usr/src/homeassistant/homeassistant/components/withings/config_flow.py", line 139, in _async_create_session
credentials = auth_client.get_credentials(code)
File "/usr/local/lib/python3.7/site-packages/nokia/__init__.py", line 86, in get_credentials
client_secret=self.consumer_secret)
File "/usr/local/lib/python3.7/site-packages/requests_oauthlib/oauth2_session.py", line 307, in fetch_token
self._client.parse_request_body_response(r.text, scope=self.scope)
File "/usr/local/lib/python3.7/site-packages/oauthlib/oauth2/rfc6749/clients/base.py", line 421, in parse_request_body_response
self.token = parse_token_response(body, scope=scope)
File "/usr/local/lib/python3.7/site-packages/oauthlib/oauth2/rfc6749/parameters.py", line 431, in parse_token_response
validate_token_parameters(params)
File "/usr/local/lib/python3.7/site-packages/oauthlib/oauth2/rfc6749/parameters.py", line 441, in validate_token_parameters
raise MissingTokenError(description="Missing access token parameter.")
oauthlib.oauth2.rfc6749.errors.MissingTokenError: (missing_token) Missing access token parameter.`
Same here. Continue running the Withings component as a custom component and everythings works. The problems appear when switching to the merged component in 0.99.
Same issue for me with the following error log: oauthlib.oauth2.rfc6749.errors.MissingTokenError: (missing_token) Missing access token parameter.
I have this message error for me
{"errors":[{"message":"redirect_uri_mismatch: The redirect URI provided is missing or does not match partner callback url"}]}
@Thomasdmm
Are you accessing HA locally? Ie 192.168.xxx.xxx Try adding
http:
base_url: https://external.domain.org
Then access it through your external address. I think you need some form of externall access to HA. But that may get addressed with the broken flow.
Yes I acces to HA locally or with my nabu account I try to put the nabu account for call back url but this doesn't work and my localy adress 10.0.x.x:8123 is not accept. I put
http:
base_url: https://external.domain.org
In the configuration.yaml ? at the beginning ?
Thnaks for help
Hello again I put
http:
base_url: https://external.domain.org
at the beginning of my Configuration Yaml I put https://external.domain.org in my callback url on the site of withings and i receive this message error
{"Error":{"Code":200,"Msg":"Invalid method"},"Method":"withings"}
I think we just need to sit and wait for now. I'm not sure if #26720 will fix the issue or if we need the Nokia python library updating? Perhaps @markc123-git can point you in the direction with the Nabu setup as it looks like that's what he is using for external access, from a couple of posts above.
When i put my nabu adress on base_url and in withings callback url I receive this message
500 Internal Server Error
Server got itself in trouble
Yea, that's correct. That's where we are getting stuck, see my first post (third one on here)
I had the same problem ( Server got itself in trouble/Missing token). I'm running HA on a raspberry in docker ( homeassistant/home-assistant:0.99.0 ).
To be able to successfully finish the config flow, I had to change a line in the nokia lib ( https://github.com/orcasgit/python-nokia/blob/1.2.0/nokia/__init__.py#L86 ). In my docker container it's in /usr/local/lib/python3.7/site-packages/nokia/__init__.py
I've added
, include_client_id=True
to the fetch_token() call.
Hi @vangorra, any chance to have this fixed soon?
My understanding of this issue is due to a change in withings API and a request as been made for the lib: https://github.com/orcasgit/python-nokia/issues/38
Same issue here, it loops then 500 error
I had the same problem ( Server got itself in trouble/Missing token). I'm running HA on a raspberry in docker ( homeassistant/home-assistant:0.99.0 ).
To be able to successfully finish the config flow, I had to change a line in the nokia lib ( https://github.com/orcasgit/python-nokia/blob/1.2.0/nokia/__init__.py#L86 ). In my docker container it's in /usr/local/lib/python3.7/site-packages/nokia/init.py
I've added
, include_client_id=True
to the fetch_token() call.
Can confirm this fix worked for me!
I'm afraid it is a bit too complicated for me. But when you have identified the problem and on top of that found a solution, we can hope that there will be a fix very soon. Could you perhaps post the revised file, so that it is just a question of copying it to the right place?
As mentioned and referenced above, this is an issue with the python-nokia library, not Home Assistant. It will need to be resolved there in order that the changes propagate through to HA.
As mentioned and referenced above, this is an issue with the python-nokia library, not Home Assistant. It will need to be resolved there in order that the changes propagate through to HA.
Yeah, and what exactly needs to be done and by whom to resolve this issue? What's expected resolution time?
@quantummobile check the link i posted above.
@quantummobile check the link i posted above.
I'm sorry, but that doesn't make things any clearer to me :)
In my docker container it's in /usr/local/lib/python3.7/site-packages/nokia/init.py I've added
, include_client_id=True
to the fetch_token() call.
Can I find this location somewhere in a hass.io install to and change it manually or do I need to wait for a patch
The maintainer of the Python script needs to release a New version that contains this fix for HA to reflect the fix. In the mean time you can change your local files as described above.
I changed it in my hassio setup today and had the same path as described.
I changed it in my hassio setup today and had the same path as described.
Hmm, I'm missing the nokia folder no such file or directory: /usr/local/lib/python3.7/site-packages/nokia/
Also checked the site-packages with ls, hassio on rpi3
Hmm, I'm missing the nokia folder
no such file or directory: /usr/local/lib/python3.7/site-packages/nokia/
Also checked the site-packages with ls, hassio on rpi3
Same here, hassio on a VM, no nokia folder
Tldr: upstream dependency needs an update, waiting for that change.
Based on my local tests, it appears withings requires a client id even though it was working before the HA release. The dependent Nokia api already accommodates this but never issued a new release. I submitted a ticket to publish the fix to pip. Then we can update component. https://github.com/orcasgit/python-nokia/issues/38
For those where the nokia folder is not in /usr/local/lib/python3.7/site-packages/ , they can try pip show nokia
and the correct location might show up.
The super brute-force method would be find / -name nokia
Hass.io-users can utilize the following work-around to fix this:
Install the "Custom deps deployment"-addon from the addon-store. Add the following to the config and run it:
{
"pypi": [
"nokia"
],
"apk": []
}
You should then in your config-folder find /deps/lib/python3.7/site-packages/nokia
.
Open __init__.py
in your favorite text editor and scroll to line 82.
Change
def get_credentials(self, code):
tokens = self._oauth().fetch_token(
'%s/oauth2/token' % self.URL,
code=code,
client_secret=self.consumer_secret)
to
def get_credentials(self, code):
tokens = self._oauth().fetch_token(
'%s/oauth2/token' % self.URL,
code=code,
client_secret=self.consumer_secret,
include_client_id=True)
Save the file and restart Home Assistant. Configure the integration again and it will finish.
edit: you should delete the nokia-folder when this evenutually is fixed in the library.
Thanks for the Hassio work around, and I'm probably being incredibly dumb here, but the Custom Deps Deployment addon seems to have been removed from the store??
@Skeletorjus you are a genius!
@ThomYoung https://github.com/home-assistant/hassio-addons-development
@Skeletorjus Bingo! It works. Thank you very much. I love this community.
@Skeletorjus you are a genius!
@ThomYoung https://github.com/home-assistant/hassio-addons-development
@wills106 amazing! Thank you! I searched, obviously not very well, I couldn't find it. It looked like it had been in the official addons and then removed.
@vangorra I forgot to thank you for a beautiful component. It works just fine, now. It has been quite a process for you and many problems were caused by other factors that you couldn't control. But now we are almost there - thanks to the fix by @Skeletorjus. With all the data you can collect about yourself and your well-being - the next "problem" is to stay relaxed without growing into a total health-freak. Once again thank you for your effort
Glad it's working for people, great component! Credit for the fix should absolutely go to @derfloh (https://github.com/home-assistant/home-assistant/issues/26716#issuecomment-533351754), I just put the pieces together for Hass.io :)
FWIW: I get the same problem, it loops then:
500 Internal Server Error
Server got itself in trouble
FWIW: I get the same problem, it loops then:
500 Internal Server Error Server got itself in trouble
Have you followed what @derfloh or @Skeletorjus have posted on how to get it working?
FWIW: I get the same problem, it loops then:
500 Internal Server Error Server got itself in trouble
Have you followed what @derfloh or @Skeletorjus have posted on how to get it working?
Yes, thanks wills106. I just wanted chime in with a +1 in order to hopefully get a quick fix for this. I do not want to install the "Custom deps deployment"-addon right now, but rather wait for an official fix.
We are waiting on the Nokia python library being updated, which is out off the hands of the HomeAssistant people.
@wills106 Is there an ongoing PR and/or issue to link to? So we home assistant users can go and try to influence the importance of this update 😄
Try to look at https://github.com/orcasgit/python-nokia/issues/38 And ask for a solution
i did the workaround and im still getting the same 500 internal server error
the maintainer confirmed the Project is dead. I'll fork and fix this weekend
Fix is ready to be merged. BTW: Here's the new maintained withings api project. https://github.com/vangorra/python_withings_api
This fix won't make it into 0.100 of HA. The maintainers reverted the fix (#27385) after the release scripts failed. This was caused by the withings-api module not using a static version number in setup.py. This has been fixed an a new PR has been submitted. #27404
If we did any of the workarounds here do we need to change something back once it's in the release?
I am really sorry but I don't get what I have to do to get my Withings devices to work with HA.
As described above, I edited my configuration.yml
and added my nabu.casa
URL as base_url
but when I approve via Withings, I just get a timeout on:
http://***.ui.nabu.casa/api/withings/authorize?flow_id=***&profile=***&code=***&state=***
Is the workaround as mentioned by @Skeletorjus still needed after the fix of @vangorra? Really confused, sorry.
If we did any of the workarounds here do we need to change something back once it's in the release?
Anyone ?
Home Assistant release with the issue:
0.99.0
Last working Home Assistant release (if known):
Operating environment (Hass.io/Docker/Windows/etc.):
Hass.io Component/platform:
https://www.home-assistant.io/components/withings/
Description of problem:
Can't authorise the app, get error:
500 Internal Server Error Server got itself in trouble
Problem-relevant
configuration.yaml
entries and (fill out even if it seems unimportant):Traceback (if applicable):
Additional information: