Open baldachyn opened 2 years ago
It uses the OOB flow which has been deprecated for any new clients it looks like. https://developers.googleblog.com/2022/02/making-oauth-flows-safer.html#disallowed-oob.
The workaround that I found to this currently is available to anyone who uses Nabu Casa or has their HA install available outside of their home network via DuckDNS or some other method.
Generate Client ID & Secret:
Web Application
and give this credential set a name (like Home Assistant Fit Credentials) + Add URI
https://<NABU_CASA_ID>.ui.nabu.casa/auth/external/callback
or https://<HOME_ASSISTANT_EXTERNAL_URL>/auth/external/callback
Create
credentials.json
Generate Token:
credentials.json
is located download the updated get_credentials.py
from this gist.get_credentials.py
in a text editor and update Line 21 to your redirect url and save.python get_credentials.py
Advanced
link and the Go to (xxxx)
Invalid state
copy the Authenticate Code from the URL. It is located between the state
and scope
url parameters and should be prefixed with code=
and end before &scope
Enter the authorization code:
prompt in your terminal and click Enter
.google_fit.token
into your HA configuration directory and restart HA.Worked for me thanks!
Didn't work for me, though :-(
When ran get_credentials.py it printed
Traceback (most recent call last): File "C:\Users\tomas\Downloads\google fit2\get_credentials.py", line 3, in <module> from google_auth_oauthlib.flow import Flow ModuleNotFoundError: No module named 'google_auth_oauthlib'
Didn't work for me, though :-( When ran get_credentials.py it printed
Traceback (most recent call last): File "C:\Users\tomas\Downloads\google fit2\get_credentials.py", line 3, in <module> from google_auth_oauthlib.flow import Flow ModuleNotFoundError: No module named 'google_auth_oauthlib'
I get the same error when I run it
Didn't work for me, though :-( When ran get_credentials.py it printed
Traceback (most recent call last): File "C:\Users\tomas\Downloads\google fit2\get_credentials.py", line 3, in <module> from google_auth_oauthlib.flow import Flow ModuleNotFoundError: No module named 'google_auth_oauthlib'
I get the same error when I run it
Just run:
pip3 install google_auth_oauthlib
Thanks ! It's working now, however I had to set the Application Type to 'Desktop Application' instead of 'Web Application' otherwise Google would block the auth
Hey @baldachyn. I updated get_credentials script but I also had to generate new credentials in google fitness API. I had to choose Desktop application, otherwise it was not working. I'll update a README file.
I was able to get the token file, but when I upload it into home assistant, I get the error below. Any ideas?
Traceback (most recent call last): File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/helpers/entity_platform.py", line 281, in _async_setup_platform await asyncio.shield(task) File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run result = self.fn(*self.args, **self.kwargs) File "/home/homeassistant/.homeassistant/custom_components/google_fit/sensor.py", line 176, in setup_platform client = _get_client(token_file) File "/home/homeassistant/.homeassistant/custom_components/google_fit/sensor.py", line 98, in _get_client http = credentials.authorize(httplib2.Http()) AttributeError: 'NoneType' object has no attribute 'authorize'
I was able to get the token file, but when I upload it into home assistant, I get the error below. Any ideas?
Traceback (most recent call last): File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/helpers/entity_platform.py", line 281, in _async_setup_platform await asyncio.shield(task) File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run result = self.fn(*self.args, **self.kwargs) File "/home/homeassistant/.homeassistant/custom_components/google_fit/sensor.py", line 176, in setup_platform client = _get_client(token_file) File "/home/homeassistant/.homeassistant/custom_components/google_fit/sensor.py", line 98, in _get_client http = credentials.authorize(httplib2.Http()) AttributeError: 'NoneType' object has no attribute 'authorize'
@grandles1212
I have the same issue
I was able to get the token file, but when I upload it into home assistant, I get the error below. Any ideas?
Traceback (most recent call last): File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/helpers/entity_platform.py", line 281, in _async_setup_platform await asyncio.shield(task) File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run result = self.fn(*self.args, **self.kwargs) File "/home/homeassistant/.homeassistant/custom_components/google_fit/sensor.py", line 176, in setup_platform client = _get_client(token_file) File "/home/homeassistant/.homeassistant/custom_components/google_fit/sensor.py", line 98, in _get_client http = credentials.authorize(httplib2.Http()) AttributeError: 'NoneType' object has no attribute 'authorize'
I too, have the same issue.
After couple of days working the integration stopped providing data, log says:
google.auth.exceptions.RefreshError: ('invalid_grant: Token has been expired or revoked.', {'error': 'invalid_grant', 'error_description': 'Token has been expired or revoked.'})
while trying to re-authenticate with google, google says
I am only one experiencing this?