vmanuel / hacs-google-fit

♥️ HACS Google Fit integration for Home Assistant
MIT License
53 stars 21 forks source link

Error: Invalid response 400. Error: invalid_scope #15

Closed rolfberkenbosch closed 1 year ago

rolfberkenbosch commented 3 years ago

Hi, first of all thank you for this nice addon!

I have followed your guide to setup google fit, but i get the following error:

Error: Invalid response 400. Error: invalid_scope
You will need to restart hass after fixing.

I can read the google calendar, and the google fit api is enabled. Do i miss something ?

rolfberkenbosch commented 3 years ago

This is the error in the homeassistant.log:

2021-06-11 09:53:11 ERROR (MainThread) [homeassistant.components.sensor] Error adding entities for domain sensor with platform google_fit
  File "/config/custom_components/google_fit/sensor.py", line 265, in device_state_attributes
AttributeError: 'GoogleFitWeightLbsSensor' object has no attribute '_attributes'
2021-06-11 09:53:11 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up google_fit platform for sensor
  File "/config/custom_components/google_fit/sensor.py", line 265, in device_state_attributes
AttributeError: 'GoogleFitWeightLbsSensor' object has no attribute '_attributes'
2021-06-11 09:53:11 ERROR (MainThread) [homeassistant.components.sensor] google_fit: Error on device update!
  File "/config/custom_components/google_fit/sensor.py", line 519, in update
  File "/config/custom_components/google_fit/sensor.py", line 310, in _get_dataset_from_last_update
2021-06-11 09:53:11 ERROR (MainThread) [homeassistant.components.sensor] google_fit: Error on device update!
  File "/config/custom_components/google_fit/sensor.py", line 457, in update
    height_datasources = self._get_datasources('com.google.height')
  File "/config/custom_components/google_fit/sensor.py", line 290, in _get_datasources
2021-06-11 09:53:11 ERROR (MainThread) [homeassistant.components.sensor] google_fit: Error on device update!
  File "/config/custom_components/google_fit/sensor.py", line 563, in update
  File "/config/custom_components/google_fit/sensor.py", line 300, in _get_dataset
2021-06-11 09:53:12 ERROR (MainThread) [homeassistant.components.sensor] google_fit: Error on device update!
  File "/config/custom_components/google_fit/sensor.py", line 730, in update
2021-06-11 09:53:12 ERROR (MainThread) [homeassistant.components.sensor] google_fit: Error on device update!
  File "/config/custom_components/google_fit/sensor.py", line 792, in update
2021-06-11 09:53:12 ERROR (MainThread) [homeassistant.components.sensor] google_fit: Error on device update!
  File "/config/custom_components/google_fit/sensor.py", line 597, in update
  File "/config/custom_components/google_fit/sensor.py", line 300, in _get_dataset
2021-06-11 09:53:12 ERROR (MainThread) [homeassistant.components.sensor] google_fit: Error on device update!
  File "/config/custom_components/google_fit/sensor.py", line 630, in update
  File "/config/custom_components/google_fit/sensor.py", line 300, in _get_dataset
2021-06-11 09:53:12 ERROR (MainThread) [homeassistant.components.sensor] google_fit: Error on device update!
  File "/config/custom_components/google_fit/sensor.py", line 663, in update
  File "/config/custom_components/google_fit/sensor.py", line 300, in _get_dataset
2021-06-11 09:53:12 ERROR (MainThread) [homeassistant.components.sensor] google_fit: Error on device update!
  File "/config/custom_components/google_fit/sensor.py", line 695, in update
  File "/config/custom_components/google_fit/sensor.py", line 300, in _get_dataset
astronaut63 commented 3 years ago

Hi - this is the problem discussed in https://github.com/vmanuel/hacs-google-fit/issues/13 and other issues and is related to the new scopes and additional protection that Google have added around personal health data

I have posted a standalone python routine in that discussion to create the required google fit token file. (As this starts an interactive browser it would be difficult to incorporate within the sensor routine)

firstchair commented 3 years ago

@astronaut63 is this used to run as https://www.home-assistant.io/integrations/python_script/ ?

astronaut63 commented 3 years ago

@firstchair No it just runs on your desktop (in a python environment) You fill in the Google clent id /secret ` etc as that you already have got and then when you run it you will see a browser open to let you agree the access (should see 10 separate permisssions to approve that match the 10 scopes) The routine generates a new token file which you can then copy and rename to match what home assistant is looking for. Might need to restart HA core after putting the file in place

firstchair commented 3 years ago

Yep, found that out. Managed to do it with "python3 script_google_fit.py --noauth_local_webserver". Didn't managed to get it up running tough, also never had the add-on running before.

ranrinc commented 3 years ago

@astronaut63 can you give some guidance on how I can run the py apps on mac? want to generate the token but so far unable to do that.

Traceback (most recent call last):
  File "google_fit.py", line 65, in <module>
    do_authentication()
  File "google_fit.py", line 37, in do_authentication
    from oauth2client import client as oauth2client
ModuleNotFoundError: No module named 'oauth2client'

I'm no python programmer so unsure.. I know need the module, but doesn't seems to run.

firstchair commented 3 years ago

@astronaut63 can you give some guidance on how I can run the py apps on mac? want to generate the token but so far unable to do that.

Traceback (most recent call last):
  File "google_fit.py", line 65, in <module>
    do_authentication()
  File "google_fit.py", line 37, in do_authentication
    from oauth2client import client as oauth2client
ModuleNotFoundError: No module named 'oauth2client'

I'm no python programmer so unsure.. I know need the module, but doesn't seems to run.

pip install --upgrade oauth2client google-api-python-client

sethakeawmok commented 3 years ago

I have the same issue ! and i cut SCOPES = ['https://www.googleapis.com/auth/fitness.body.read', 'https://www.googleapis.com/auth/fitness.body.write', 'https://www.googleapis.com/auth/fitness.activity.read', 'https://www.googleapis.com/auth/fitness.location.read']

after it work but not show heartrate and token use 1 hour not update

sharoltd commented 2 years ago

Hi - this is the problem discussed in #13 and other issues and is related to the new scopes and additional protection that Google have added around personal health data

I have posted a standalone python routine in that discussion to create the required google fit token file. (As this starts an interactive browser it would be difficult to incorporate within the sensor routine)

My sensor updated only during HA restarting. is it possible to make updating by automation? Thanks

ChristianHahnBPEX commented 2 years ago

everything works now. just had to go to my google account remove access from home assistant, reauthenticate and finally getting all the sleep data + token doesnt expire

sharoltd commented 2 years ago

everything works now.

With this intergation https://github.com/vmanuel/hacs-google-fit ?? How many days is the token already?

harphere commented 2 years ago

everything works now. just had to go to my google account remove access from home assistant, reauthenticate and finally getting all the sleep data + token doesnt expire

Did you run any of the Python scripts mentioned previously?

vmanuel commented 1 year ago

I have not maintained this repository for a long time. I think the HACS from https://github.com/YorkshireIoT/ha-google-fit is perfect