Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

Error: Invalid response 400. Error: invalid_scope #15

Closed
rolfberkenbosch opened this issue Jun 11, 2021 · 13 comments
Closed

Error: Invalid response 400. Error: invalid_scope #15

rolfberkenbosch opened this issue Jun 11, 2021 · 13 comments

Comments

@rolfberkenbosch
Copy link

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
Copy link
Author

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
Copy link

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)

@firstchair
Copy link

@astronaut63
Copy link

astronaut63 commented Jun 14, 2021

@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
Copy link

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
Copy link

ranrinc commented Jun 17, 2021

@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
Copy link

firstchair commented Jun 17, 2021

@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
Copy link

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
Copy link

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
Copy link

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
Copy link

sharoltd commented Jan 15, 2022

everything works now.

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

@harphere
Copy link

harphere commented Feb 7, 2022

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
Copy link
Owner

vmanuel commented Oct 31, 2023

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

@vmanuel vmanuel closed this as completed Oct 31, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants