Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'invalid_client' on restart #26

Open
coharness opened this issue May 26, 2022 · 21 comments
Open

'invalid_client' on restart #26

coharness opened this issue May 26, 2022 · 21 comments

Comments

@coharness
Copy link

I already have a couple of other Google integrations (Calendar and TTS). I added the Fitness API to my Home Assistant project on the Cloud Console. When I restart Home Assistant this is the error I get in notifications.

Error: Invalid response 401. Error: invalid_client
You will need to restart hass after fixing.
@Crickus
Copy link

Crickus commented May 30, 2022

The same issue. Updated HA to 5.2022 version from 4.2021 and integration stopped working

@Crickus
Copy link

Crickus commented Jun 1, 2022

Something completely wrong with authorization. Old token file gives 401 error. New file can't be created, because authorization procedure doesn't start. Standalone authorisation python script from community doesn't accept the code returned by Google.
Looks like oath2 procedure has changed again or something

@Crickus
Copy link

Crickus commented Jun 7, 2022

Did some investigation about the problem.
Old token files was made with oath2 credential type "Desktop". Home Assistant gives 401. Error: invalid_client error for this type of tokens now. New tokens of this type could be obtained, but can't be used with Home Assistant.
Due to installation manual on this git you should make oath2 credential with type "TV and Limited Input". This credentials can't be obtained due to new Google security policy. Add-on gives 400: invalid_request error with "redirect_uri: urn:ietf:wg:oauth:2.0:oob" message.
Could author repair authentication procedure of the component, please?

@weesteev
Copy link

Any movement on this one, still nothing for 2022.6.5. Integration installs ok but sign in fails with the same 401 error for me.

@tomhash2
Copy link

I confirm that neither "Desktop" nor "TV and Limited Input" credential type does not wok.

@cyberjunky
Copy link
Owner

Can you try if downgrading to 1.0.5 helps? That uses older (very old) oauth2 and google api's package.
Trying to reproduce this, but didn't succeed yet.

@tomhash2
Copy link

tomhash2 commented Jun 13, 2022

So now, with "TV and Limited Input", I have:

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

This is related to changes Google made to API:
vmanuel/hacs-google-fit#13
vmanuel/hacs-google-fit#15
https://support.google.com/cloud/answer/9110914#restricted-scopes&zippy=%2Cgmail-drive-and-google-fit-apis

@tomhash2
Copy link

Best method for dealing with "invalid_scope" is:
IvanVojtko/googlefit-homeassistant#10

@AFMHARoma
Copy link

AFMHARoma commented Jun 14, 2022

Best method for dealing with "invalid_scope" is: IvanVojtko/googlefit-homeassistant#10

Getting token file is ok, but error while decoding to utf8:
'utf-8' codec can't decode byte 0x80 in position 0: invalid start byte

Script saves token in strange format, which is not exactly a bytestring.

@Crickus
Copy link

Crickus commented Jun 14, 2022

I did some testing today.
All types of credentials except "TV and Limited Input" gives 401 invalid_client error. "TV and Limited Input" gives 400 invalid_scope error.
I tried different version of this integration 1.0.2-1.0.7 with no luck.
It doesn't matter do you have previously generated token file or not. Integration ignores old files (from previous HA version) and new ones (generated with different versions of get_credential script).

@Andrewdlec
Copy link

Are there any updates you can provide on this issue? I recently came across your integration and am excited to get it set up, but am facing the same issue listed in this thread. I have tried changing my time zone but no luck so far. Thanks!

@Crickus
Copy link

Crickus commented Jul 6, 2022

I managed to fix invalid scope error with deleting heart_rate and sleep scopes from sensor.py. After that I just changed time zone and token was received.
I know that @cyberjunky got correct scopes list from https://developers.google.com/identity/protocols/oauth2/scopes#fitness
But it's not work normally with authorization string for some reason
изображение

@demoneto
Copy link

I managed to fix invalid scope error with deleting heart_rate and sleep scopes from sensor.py. After that I just changed time zone and token was received. I know that @cyberjunky got correct scopes list from https://developers.google.com/identity/protocols/oauth2/scopes#fitness But it's not work normally with authorization string for some reason изображение

Thanks. It worked out.

@Andrewdlec
Copy link

I managed to fix invalid scope error with deleting heart_rate and sleep scopes from sensor.py. After that I just changed time zone and token was received. I know that @cyberjunky got correct scopes list from https://developers.google.com/identity/protocols/oauth2/scopes#fitness But it's not work normally with authorization string for some reason изображение

Dang. I was really hoping this would work. I made the change. Set my timezone to GMT no daylight savings and rebooted. Same problem as before.

Gibby pushed a commit to Gibby/home-assistant-google_fit that referenced this issue Jul 25, 2022
@xeor
Copy link

xeor commented Aug 5, 2022

This plugin is currently broken on all new installs, but removing those 2 scopes and temp-timezone seams to work.. Are those two scopes really needed? Or is removing them a temporary fix that just waits to break because google deprecates something?

@Andrewdlec
Copy link

I've tried auth with a Web client ID and a Desktop client ID. I've removed the two scopes, changed my time zone and rebooted multiple times. No luck here.

@cyberjunky
Copy link
Owner

The two scopes are valid scopes and have same auth requirements as the others, so not sure what the issue is yet...
I guess all need to be rewritten to use newer > v1 API

@sam2332
Copy link

sam2332 commented Oct 4, 2022

can we revert the breaking changes or is this plugin dead?

@weesteev
Copy link

weesteev commented Oct 4, 2022

I haven't found a version that this works with and it doesn't seem like anyone wants to try and fix this either which is a shame!

@cyberjunky
Copy link
Owner

Install visual studio add-on, open it, open file 'config/custom_components/google_fit/sensor.py' remove the lines above, restart HA, and you know it... if you can edit yaml file, you can do this too, it's no rocketscience you know..

@Ties1208
Copy link

I have the same issue. And i did delete the 2 lines at the scopes in the sensor.py file but it still has the same error... is there an other solution?

@jellewie jellewie mentioned this issue Apr 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests