endoplasmic / google-assistant

A node.js implementation of the Google Assistant SDK
MIT License
283 stars 75 forks source link

It returns `invalid_grant` after a few days #95

Closed Aymkdn closed 3 years ago

Aymkdn commented 3 years ago

Hi,

I configured everything and it worked great… but after a few days it stopped working and the program now returns an invalid_grant. I changed nothing on my side, so I'm wondering what could cause this issue?

Auth error:Error: invalid_grant Conversation Error: Error: 14 UNAVAILABLE: Getting metadata from plugin failed with error: invalid_grant

Before spending time redoing the whole registration and oauth process, I wanted to make sure it won't happen again in a few days?!

Thanks

bugsounet commented 3 years ago

Hi, I test your patch, the result is the same: Error: invalid_grant invoqued by oauthClient.refreshAccessToken() line

working around too

Aymkdn commented 3 years ago

It might be because the project is in test and the refresh token is only valid during 7 days. I've been told to publish the project... I tried to publish it in alpha mode but the Google Console website returned an error. I wanted to try again later and see if it's enough.... So it might not be an issue with this library.

Aymkdn commented 3 years ago

On this page, it says:

A Google Cloud Platform project with an OAuth consent screen configured for an external user type and a publishing status of "Testing" is issued a refresh token expiring in 7 days.

I tried to publish my project to "alpha" channel but it returns an useless error and now I'm stuck...

Aymkdn commented 3 years ago

OK, actually I think it's from this screen: https://console.cloud.google.com/apis/credentials/consent?project=PROJECT_NAME

There is "Publication State", and it's currectly in "testing". From there you can click on the publish button.

endoplasmic commented 3 years ago

I had the same error and after going down a rabbit hole, it looks like Google changed how OAuth worked. Your OAuth consent screen should look like this: image

I then deleted my tokens.json file (or whatever you have set in savedTokensPath), reran the script, did the OAuth flow, and now things are running fine.

Also just to double check, you need to make sure you've got the API enabled as well: https://console.cloud.google.com/marketplace/product/google/embeddedassistant.googleapis.com?q=search&referrer=search&project=PROJECT_ID_HERE

Aymkdn commented 3 years ago

Thanks. It should be good with my last comment.