0

I am making a smart home app using Actions On Google. I currently have a Firebase cloud function that calls the HomeGraph API with a Request Sync request.

Here's the contents of the function:

const {smarthome} = require('actions-on-google');

const app = smarthome({
  key: "(My Key)"
});

//Assume UID is the id of the user that we are requesting a sync for
app.requestSync(uid).then((res) => {
  return;
}, (e) => {
  console.error(e);
});

In the logs for this function, I am getting the error:

{ "error": { "code": 403, "message": "The caller does not have permission", "status": "PERMISSION_DENIED" } }

This error seems like a standard Google API permission denied error response, but when would it happen in a Request Sync HomeGraph API call?

yummypasta
  • 1,398
  • 2
  • 17
  • 36

1 Answers1

0

I was having this problem for quite a long time, and I decided to post the question and answer here so others don't have to spend wasted time troubleshooting.

There are two potential causes for this error to occur.

  1. The most logical cause: make sure you provide a valid API key in the data passed in to the smarthome constructor. The example in the question is correct (of course, replace (my key) with the key you made in the console.
  2. This was the cause of the error that I ran in to: make sure the uid you pass in to requestSync() is a valid user ID. There was a flaw in my SYNC code, therefore the user did not get created. I struggled so much on diagnosing this problem because the error message does not make sense.

Hope this helps to anyone with this problem.

yummypasta
  • 1,398
  • 2
  • 17
  • 36
  • Based on reading the question, I think the error is more of the former, where you were not authorized to call the API. If the user doesn't exist, I think you get a 404 error. – Nick Felker Mar 25 '19 at 13:37
  • @NickFelker That's what I thought at first, but I made sure my key was valid and the HomeGraph API was enabled. The error message doesn't really make sense for case 2, but that's what fixed it for me. – yummypasta Mar 25 '19 at 15:40