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

Getting metadata from plugin failed with error: invalid_grant #222

Open
HeedfulCrayon opened this issue Dec 26, 2020 · 74 comments
Open

Getting metadata from plugin failed with error: invalid_grant #222

HeedfulCrayon opened this issue Dec 26, 2020 · 74 comments

Comments

@HeedfulCrayon
Copy link

Describe the bug
Assistan relay seems to lose auth after a while. Whenever testing anything in sandbox I get this error:
Getting metadata from plugin failed with error: invalid_grant

To Reproduce
Steps to reproduce the behavior:
Try any command in sandbox

Expected behavior
Command or broadcast to occur without issue.

Desktop (please complete the following information):

  • Platform Pi 4 running home assistant
  • Browser vivaldi
  • Version latest
@jayhohoho2019
Copy link

I just got exactly the same issue. its been working for about a week. I had to create another user using the same OAuth client ID. why is that?

@jesselumarie
Copy link

Also seeing this issue

@littlbee
Copy link

Same issue, and also solved by creating a new user using the same credentials.

@HeedfulCrayon
Copy link
Author

Creating a new user only fixes it temporarily. After a few days it will go back to doing the same thing

@jesselumarie
Copy link

jesselumarie commented Dec 29, 2020 via email

@matt---4
Copy link

matt---4 commented Jan 2, 2021

Also getting this, going to try running a command to ask the time every six hours to see if that stops any timeout.

@jayhohoho2019
Copy link

Happening to me again, 7 days after. Who is causing this to expire? GAR or Google?

@thomasbonte
Copy link

Same for me. @matt---4 Any luck with your testing to repeat a command every X hours?

@matt---4
Copy link

matt---4 commented Jan 6, 2021

So far the issue hasn't happened since I started asking the time every six hours. I'll post back on here in a week or so with another update or if the issue happens again.

@thomasbonte
Copy link

@matt---4 ok good to know! I'll be testing this myself as well.

@Snacker001
Copy link

Snacker001 commented Jan 6, 2021

I'm having the same issue and have automations which run daily at minimum firing commands. All working fine until 4 days ago with nothing having changed but now with the invalid_grant error. Same happens if I fire from sandbox mode.

EDIT - FYI I also added a new user using the same auth creds and it works again with this new user. I will monitor to whether this user gets impacted over time

@abdalians
Copy link

me 3

@littlbee
Copy link

littlbee commented Jan 9, 2021

I'm a bit concerned the dev doesn't seem to react on this issue... Is there anyone still maintaining this code ?

@HeedfulCrayon
Copy link
Author

I'm a bit concerned the dev doesn't seem to react on this issue... Is there anyone still maintaining this code ?

Calm down, last commit was 14 days ago. Just set up an automation to run every 6 hours like stated above and you won't lose auth. Mines been working fine for over a week

@Snacker001
Copy link

Not sure the regular automation trick works. I set up a new user to prevent the problem on the current user, set up an automation to run every 5 hours. It was fine for the first day and now is failing with the invalid_grant error again

@matt---4
Copy link

My raspberry pi crashed and I got invalid grant when it started up again. So I don't know how long the automation thing would have worked for.

@matteskonto
Copy link

matteskonto commented Jan 14, 2021

Both my users lost the grant at the same time, one was used much more frequently than the other so I doubt it is interaction dependent. It was also 7 days after I set the system up.

Is there maybe something with the testing function that are used for the grants?

@HeedfulCrayon
Copy link
Author

Just saying, mine is still going just fine

@Snacker001
Copy link

@HeedfulCrayon that's good. What environment are you using this in? For me I am using the Home Assistant add-on and triggering automations through node-red. Curiously at the moment I get the error only in node-red, but can still successfully use the sandbox mode to trigger directly on the latest user account. My original user account fails in both Node-red and sandbox.

I might try installing a separate instance on a VM and see how that goes.

@HeedfulCrayon
Copy link
Author

@Snacker001 I am using it in the Home Assistant add-on and I am using the native yaml automations:

id: 'google_assistant_relay_heartbeat'
alias: Google Assistant Relay Heartbeat
description: 'Keeps the token for Google Assistant Relay Alive'
trigger:
  platform: time
  at:
    - "09:30:00"
    - "12:00:00"
    - "18:00:00"
    - "00:00:00"
    - "06:00:00"
action:
  - service: rest_command.assistant_relay
    data:
      command: What time is it?

@ryancasler
Copy link
Contributor

Don't think this is a GAR problem. I am not seeing any problem running in Docker on Ubuntu. It can be days between broadcasts and I'm not having any problems.

@mbaluda
Copy link

mbaluda commented Jan 17, 2021

I see the same behavior

@peterolby
Copy link

I'm having the same issue. Have not been tracking but would guess I loose grant after about 4 days.
Will set up automation to track this more closely.

@HeedfulCrayon
Copy link
Author

Mine finally died. Looks like running an automation periodically doesn't seem to fix the issue

@wolfet410
Copy link

I ran into the same problem twice now, it does not appear to be related to lack of activity. I'm posting in case my experiences help narrow down the problem.

The first failure, my Pi lost power hard and didn't boot back up properly. After solving the boot problem, I still received the invalid_grant errors. I didn't do any other testing, I reloaded the OS on the Pi and started over.

The second time, last night, I was actively sending commands when the credentials began failing. I sent 475 commands in 1 day successfully and began receiving the invalid_grant error on the 476th command.

The Google Assistant API reported "1 of 1 quota is reaching limit", the quota is 500 requests per day so I was near it.

I confirmed Google reported the Assistant API quota reset overnight, but I was still getting the same invalid_grant response this morning. I created a new Assistant-Relay user with no other issues to temporarily mitigate the problem.

@ryancasler
Copy link
Contributor

What environment are you running GAR in? I am running in a plain Linux Alpine based Docker container and I am not having this problem. I would look more at what your OS might be contributing to this. If it was a GAR problem, we would all be seeing it.

@jayhohoho2019
Copy link

I've been having the same issues. I thought it was occurring every 7 days for me (Sunday to Sunday) but I lost it again today after really 2 day, after I had also set up another webCoRE piston to ping every 5 hours. I'm on a Ubuntu vm on vmware running on a Windows 10 host. And I don't think I would have hit the 500 requests per day limit. This is getting really annoying.

@Snacker001
Copy link

Has this problem a few times when deploying AR via the Hassio add-on. Since moving it to run on a VM running ubuntu18.04 it has not reoccurred.

For what it's worth I have a benign automation running every 5 hours, but I am not sure that really helps - it certainly didn't when running the hassio add-on. I am also nowhere near the 500 per day request rate.

@wolfet410
Copy link

I do not think the problem is only caused by exceeding the quota.

Just speculation, but it seems once the invalid_grant error appear for whatever different reason it does not recover until a new user is created. Even if the root cause of the invalid_grant error gets solved (i.e. timeout no longer occurs, quota has expired, etc) that user won't stop reporting a failure. Problems like timeouts or disconnects that occur for reasons completely unrelated to GAR, and would normally be solved by sending another request, ultimately stop the service until manual intervention.

If that's the case, I agree a more powerful server would have less of a chance of initial failure avoiding this issue altogether.

@FaberOptime
Copy link

I too am encountering this issue.
GAR v3.2.0 running on Win10.

@jayhohoho2019
Copy link

Update. So it's been 15+ days for me and still works (no invalid_grant error). Anybody else successful in reproducing what I did?

@jesselumarie
Copy link

jesselumarie commented Feb 6, 2021 via email

@Snacker001
Copy link

Update. So it's been 15+ days for me and still works (no invalid_grant error). Anybody else successful in reproducing what I did?

I "published" 4 days ago and fine so far. Mine typically failed after a week, so still unproven for me but fingers crossed!

@Snacker001
Copy link

Snacker001 commented Feb 10, 2021

So by way of update, a week on and having published on the developer console it has fallen over again. A quick remove and re-add user with the same client_secret and back up.

Interestingly, I also have a similar issue with Nest, again on almost a weekly basis it fails and needs re-authenticating via the integrations pain. Looking into that it seems there are issues where google invalidates the tokens:

https://github.com/home-assistant/core/issues/44584

https://developers.google.com/identity/protocols/oauth2#expiration

@ryancasler
Copy link
Contributor

How many users do you have set up for the project? I only have one and I have never had this problem. I just use the same Oauth client everywhere (since they are all me).

@Snacker001
Copy link

Only 1 user for me too and GAR probably only triggers commands around 10 times a day, so should be nowhere near quotas

@matteskonto
Copy link

I have it running now for 10 days without issue after I made the apps in Production status for two users (one project each)

@jayhohoho2019
Copy link

Did you get an unverified app message from Google when adding the user?

@matteskonto
Copy link

Not anymore, I still get the 100 logins limit when creating a new OAuth client

@jesselumarie
Copy link

mine still seems to be working too (it was off for a few days, as my kid apparently unplugged my raspberry pi 😅), but after starting up the server again it's working without having to redo my credentials.

@craigmcgowan
Copy link

Getting the same issue, thankfully resolved by resetting my user as suggested above. Look forward to a full time fix

@jayhohoho2019
Copy link

You are still getting this issue even after publishing the app?

@craigmcgowan
Copy link

Ill try that. I had thought that I saw a comment saying it didnt work so I never tried it. Have just published it now.
Thank you

@Snacker001
Copy link

At the risk of tempting fate, 11 days on and still working. In case it makes any difference this is the first time it has been "reactivated" post publishing the app, rather than publishing it after authenticating last time. Fingers crossed

@jesselumarie
Copy link

Mine is still working, nearly two weeks after publishing

@pickonedev
Copy link

solved

This addon was not updated for almost half of Year... What can you ask more to work? Nothing! The addon it is almost dead...

@henning334
Copy link

So by way of update, a week on and having published on the developer console it has fallen over again. A quick remove and re-add user with the same client_secret and back up.

Interestingly, I also have a similar issue with Nest, again on almost a weekly basis it fails and needs re-authenticating via the integrations pain. Looking into that it seems there are issues where google invalidates the tokens:

https://github.com/home-assistant/core/issues/44584

https://developers.google.com/identity/protocols/oauth2#expiration

Is it still working for you after publishing it again?

I'm pretty new to GAR, and noticed in the last few days that it stopped working. Found i get the same error "UNAVAILABLE: Getting metadata from plugin failed with error: invalid_grant" as you guys are.

Will try to publish the app, but i'm not certain thats a permanent fix.
If it is, i suggest install guides/instructions are updated with this info.

@jonathanbower
Copy link

Publishing the app is not a solution. Mine just failed after about three weeks.

@Snacker001
Copy link

Mine is still working fine post publishing 20 days ago.

@craigmcgowan
Copy link

Mine has failed since publishing 9 days ago too.

@ryancasler
Copy link
Contributor

Yours has failed or has not failed?

I'm pretty sure I said that pushing to production was the solution back in January if I'm not mistaken. I have screenshots from the setup and I'll put a step-by-step together for the future.

@craigmcgowan
Copy link

Yes mine has failed. I published around 11 days ago.and already again I get the invalid grant error.

@jayhohoho2019
Copy link

Mine has been working since Jan 25th. Here are my observations from a previous post:
Fyi yesterday after I published the app (so its status became In Production) in the developer console, I also got the new verification status which is Verification Not Required. After that when I added a new user, I no longer got the Unverified App warning.

I think if you don't get the unverified app warning when you add a new user you should be fine.

@rocker01
Copy link

I've been facing this issue regularly too. Have v3.2.0 running on a Raspberry Pi 4 (4GB model), and after a few days I start getting this error message. The only solution to this has been to either reinstall Assistant Relay or remove and re-add my user.

I appreciate all the work that must have gone into creating this project, and it is honestly incredible - the only this that is keeping it from greatness is this annoying bug!

@drinfernoo
Copy link

drinfernoo commented Jun 21, 2021

I can confirm I'm also seeing this same behavior in 3.2.0:

/root/.pm2/logs/www-error.log last 15 lines:
0|www      |   details: 'Getting metadata from plugin failed with error: invalid_grant'
0|www      | }
0|www      | Auth error:Error: invalid_grant
0|www      | Error: 14 UNAVAILABLE: Getting metadata from plugin failed with error: invalid_grant
0|www      |     at Object.exports.createStatusError (/assistant_relay/node_modules/grpc/src/common.js:91:15)
0|www      |     at ClientDuplexStream._emitStatusIfDone (/assistant_relay/node_modules/grpc/src/client.js:233:26)
0|www      |     at ClientDuplexStream._receiveStatus (/assistant_relay/node_modules/grpc/src/client.js:211:8)
0|www      |     at Object.onReceiveStatus (/assistant_relay/node_modules/grpc/src/client_interceptors.js:1311:15)
0|www      |     at InterceptingListener._callNext (/assistant_relay/node_modules/grpc/src/client_interceptors.js:568:42)
0|www      |     at InterceptingListener.onReceiveStatus (/assistant_relay/node_modules/grpc/src/client_interceptors.js:618:8)
0|www      |     at /assistant_relay/node_modules/grpc/src/client_interceptors.js:1127:18 {
0|www      |   code: 14,
0|www      |   metadata: Metadata { _internal_repr: {}, flags: 0 },
0|www      |   details: 'Getting metadata from plugin failed with error: invalid_grant'
0|www      | }

This happens after a few days, and when I try to broadcast (via an HA automation), I still get the "broadcast chime" noise playing, but then nothing is spoken. Deleting the user and re-adding it (even with the same credentials) does seem to work for awhile, as others have said.

@lazdavila
Copy link

Update. Still working for me after 8+ days. It always expired in 7 days or sooner before. What I did was I published the app in the developer console (status showing In Production). Verification status is Verification Not Required. I didn't get the Unverified App warning after this, when I added a new user. Notice this: if your users are seeing the "unverified app" screen , it is because your OAuth request includes additional scopes that haven't been approved.

... just in case anyone else is also having problems figuring out how to 'publish' the app (took me ages to find it), it is under: https://console.cloud.google.com/apis/credentials/consent, in the "Publishing Status" section. After doing this, I also removed and re-added the user in the relay site, and confirmed that I did not get the "Unverified App" warning.

@dotrooster
Copy link

I wasn't sure if I should start a new thread or just tack onto this one since my issue is related. Sorry if I'm in the wrong place.

I've been having the same invalid_grant issue as everyone else, but when I try to publish the app and then re-create the user in RA, I get an "Error 400: invalid_request: message where I should be seeing an option to login to my google account. Specifically, the probelm is apparently with "redirect_uri: urn:ietf:wg:oauth:2.0:oob". Anyone know where I'm going wrong?

Thanks!

@techtom609
Copy link

I wasn't sure if I should start a new thread or just tack onto this one since my issue is related. Sorry if I'm in the wrong place.

I've been having the same invalid_grant issue as everyone else, but when I try to publish the app and then re-create the user in RA, I get an "Error 400: invalid_request: message where I should be seeing an option to login to my google account. Specifically, the probelm is apparently with "redirect_uri: urn:ietf:wg:oauth:2.0:oob". Anyone know where I'm going wrong?

Thanks!

Im running into this same exact issue. I have tried absolutely everything but cannot get passed this error. Any ideas?

@jiffyjaff
Copy link

Your issue is the same as what I've reported here.

#266

@techtom609
Copy link

techtom609 commented Mar 9, 2022 via email

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