ismarslomic / google-assistant-broadcast

Broadcast message to your speakers with Google Assistant without interrupting your music
31 stars 9 forks source link

Getting error as response when broadcasting a message #7

Closed chrisjenx closed 2 years ago

chrisjenx commented 2 years ago

Hey thanks for putting this together, unforutnatly after getting the token and client_secrete when sending curl commands to the docker container all I get is error outputs:

Checked Google API console, no requests ever hit it, so looks like an issue before it even gets that far, fyi I'm running docker on x86 machines, not sure if that makes a difference considering it's node?

image

chrisjenx commented 2 years ago

I was trying to run the server locally to debug but node dosn't want to play ball, I think I got node to work once in my life:

{"error":{"code":"MODULE_NOT_FOUND","requireStack":["/Users/chrisjenkins/git/google-assistant-broadcast/node_modules/google-assistant/components/auth.js","/Users/chrisjenkins/git/google-assistant-broadcast/node_modules/google-assistant/index.js","/Users/chrisjenkins/git/google-assistant-broadcast/assistant.js","/Users/chrisjenkins/git/google-assistant-broadcast/index.js"]}}%

Followed all google steps for cleaning/reinstall 🤷

ismarslomic commented 2 years ago

The error handling and error messages are currently not quite useful. Will take a look at it!

However, what node is trying to tell you is that it fails importing client secret and tokens file.

You can set path to these two files by starting node with env vars mentioned in line 8 and 12 in assistant.js

chrisjenx commented 2 years ago

The docker container can see and access these files as I can cd and cat the files inside the container. So I'm a little confused. Maybe I fat fingered a name...

On Wed, Jun 8, 2022 at 11:29 PM Ismar Slomic @.***> wrote:

The error handling and error messages are currently not quite useful. Will take a look at it!

However, what node is trying to tell you is that it fails importing client secret and tokens file.

You can set path to these two files by starting node with env vars mentioned in line 8 and 12 in assistant.js https://github.com/ismarslomic/google-assistant-broadcast/blob/main/assistant.js

— Reply to this email directly, view it on GitHub https://github.com/ismarslomic/google-assistant-broadcast/issues/7#issuecomment-1150686499, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAI5DMINLHDRHMA7I25WUKDVOF6L5ANCNFSM5YIUVMHA . You are receiving this because you authored the thread.Message ID: @.***>

chrisjenx commented 2 years ago

OK got it working locally, without a better error in the docker container not sure where to go there. However this got me thinking about https://developers.google.com/assistant/smarthome/develop/notifications#java I might throw something together to see if works how I think it should

ismarslomic commented 2 years ago

You started index.js in Node locally and then it worked?

chrisjenx commented 2 years ago

Yeah works locally (I just set the tokens and client secret with full path from root and it worked).

Still no luck on docker, files are readable and accessable inside the docker container and the error is just blank as above. Not sure if theres any better error logging to be had?

ismarslomic commented 2 years ago

I did release new version 1.0.5 of Docker image today. I added validation of required files, checking if they exist. You could give it a try? I dont get why Docker should introduce any issues here..

chrisjenx commented 2 years ago

Just updated, started up fine, same issue.. no error in logs too, super weird..

➜ ~ curl -X POST http://10.10.106.2:8085/broadcast \ -d '{"message":"Hello world!!"}' \ -H "Content-Type: application/json" {"error":{}}%

ismarslomic commented 2 years ago

While doing some testing few minutes ago, I experienced same issue on my side. Everything looked correct, but response where empty error. And I managed to fix it 🥳 .

Issue where that I downloaded the OAuth 2.0 credential file for my registered device from the Google Actions Console and used that to generate the OAuth Token (with use of google-assistant-oauth docker container). When I tried to use the client_secret.json and tokens.json, I received error as response.

google-actions-console

But, when I used the OAuth client file, downloaded from the Google Cloud Platform console, then it worked.

gcp-console

I looked at the content of these two files and the main difference where on two places:

OAuth 2.0 credential file:

{
  ...
  "token_uri": "https://accounts.google.com/o/oauth2/token"
}

OAuth client file:

{
  ...
  "token_uri": "https://oauth2.googleapis.com/token",
  "redirect_uris": [
      "http://localhost"
  ]
}

So you could check which of these files you are using, and try to download the one from GCP Console.

chrisjenx commented 2 years ago

Yup that missing "token_uri": "https://accounts.google.com/o/oauth2/token" fixed it for me instantly, interesting!

Not sure why running locally worked with the files missing those...

ismarslomic commented 2 years ago

Nice! Happy to see that you are finally up and running with google-assistant-broadcast docker container!

I have added new validation steps in both docker images, so new folks can easily identify this issue. Thanks for reporting this issue!

Can we close this issue now?

chrisjenx commented 2 years ago

Yes thank you!