-
Notifications
You must be signed in to change notification settings - Fork 21
How to resolve the issue with the new API's #13
Comments
I thik it is because now they are restricted scopes... |
I tried this manual solution as posted above and on https://community.home-assistant.io/t/google-fit-support/4556/180 and it worked initially but then stopped The first was using the same method as the various google fit sensors (calling oauth2client.client.Oauth2Webserverflow and then ...step1_get_device_and_user code() from the Google api python client) .. when this works then it gives you a code to enter at www.google.com/device. With this routine it was quick to try different sets of scopes and see which work/didn't work and also use the debugger to confirm that it is the google server rejecting the requests In the second method I used oauth2client.tools.run_flow which then takes you through the browser based authorisation and returns the credentials needed. The routine then writes these into a file whcih can then be renamed to match your expected google fit sensor token file . Results - as we have all found, any use of the new scopes with the get_device_and_user_code routine fails (and fails after the data has been sent across to https://oauth2.googleapis.com/device/code Better news is that the second method (generating the token file) has been running for 48 hours now and is still collecting steps, heart rate and sleep data. Code for second routine
|
@astronaut63 Trying to implement the first method, however, keep getting hit by 400 error message. On AuthPlayground, if I enter my credential and id token, it will also fail to authorize it with a 400 error. Trying to the your 2nd method but still can't figure it out how to put the code? Should I create a new py? Put it in the custom components/google_fit? The name? Thanks for at least a solutions |
@astronaut63 i try you fix, but still get the Google Fit Setup I place the google_fit.token in the /config map and restart HA, but still the above error. Am i missing something ? |
Some of this is covered in #15 and thanks to @firstchair for the command lines to run the routine (and to install the necessary modules)
The token file expected is .[name]_[platform] If you have created the token file and are getting the Error 400 invalid scope error then this means that the sensor.py did not find the token file and has then tried to request authorisation of the scopes using the ...step1_get_device_and_user code() in routine do_authentication (if the file exists then no call is made to do_authentication) --- so please check again the token file name |
Go it working.. Thanks, @astronaut63 @firstchair for all the help |
I have created the token file (after a lot of extra steps, updating python to get oauth2 etc) |
once you get the new token.. you need to add it to your current google fit token on your HA. |
I simply copy the complete token file into the config folder (and then restart HA - usually just restarting core seems to work) |
Thanks.. copied it into the config folder |
I already have a .google.token file. Don't know if that's the reason, but this isn't creating a ._google_fit token automatically... |
I think they may have changed the API again, mines stopped working |
Anyone else able to comment I cant get this working again either. |
Has this fix been committed to any working branch of this repo? |
My sensor updated only during HA restarting. is it possible to make updating by automation? |
@cskiwi can you have date from sleep time and heart sensor?? |
do still have this script? |
hi guys thanks all those indications. I still do have a problem when running the script. google seems to stop the request. _You can't sign in to this app because it violates Google's OAuth 2.0 app security policy. Any ideas? |
The script runs standalone e.g. in a python environment or if you look at an older post there is a link to a command line. I ran the script 11 days s ago and it works as expected - it asks me which google account I want to use, it then warns me that the app is not yet verified by Google and then when I proceed I get promoted to tick the 10 different data types I am giving access to. This then created the new token file which I copied to Home Assistant (and restarted HA) Just tried again and the routine to create the token it is still working |
Is there a video somewhere for the really stupid like me? |
I can confirm the authorization error reported earlier is still an issue when using the script. |
For users having issues with the updated heart rate and sleep permissions:
I tried first adding the required scopes to the
sensor.py
removing my token file but then I got ainvalid_scope
error, I searched a bit, but couldn't figure out why.After some more messing around I found a method that seems to work
Required;
Let's goo!
Go to oauthplayground
Click on "Step 1 Select & authorize APIs"
Scroll down to
Fitness API v1
Normally all scopes should be enabled with read and write (this isn't fully needed, but I didn't had the time to fully figure out what needs to be enabled)
If not, these are the ones that worked for me:
Click on "Auhtorize APIs" and go trough the authorization steps
In step 2, click on
Exchange authorization code for tokens
On the right you should see something like this:
copy the full json part on the bottom (with the access_token, scope, ...)
open your
.<name>_google_fit.token
file. This should be on the same level as yourconfiguration.yaml
file (I suggest you create a copy and format it, for easy working and having a backup)Paste the copied json in the
token_response
part (this should have the same keys, maybe different order)Copy the full
access_token
(yellow in reference screenshot), fullrefresh_token
(purple in reference screenshot) to the upper part of the jsonCopy the following scopes (green in reference screenshot) to the scopes part (remove the ones you didn't authorize):
Refrenced screenshot of my
<name>.google_fit.token
file (not my full tokens obvisouly) :I'm still waiting for a new token token to be generated, but this should give any issue (from my knowledge of these tokens, but then again I don't understand why the scope was giving issues)
The text was updated successfully, but these errors were encountered: