actions-on-google / actions-on-google-nodejs

Node.js client library for Actions on Google
https://actions-on-google.github.io/actions-on-google-nodejs
Apache License 2.0
900 stars 197 forks source link

Error when calling requestSync #360

Closed fabltd closed 4 years ago

fabltd commented 4 years ago

When trying to call requestSync in NodeJS the follow undocumented error is shown:

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

Operation is the same with an API key and Service account.

The same API Key and agentUserId will work with curl!

Fleker commented 4 years ago

Are you using both an API key and a service account key?

fabltd commented 4 years ago

I have tried Just API Key. Just Service account and both. It all cases this command fails.

reportState works with no issue.

fabltd commented 4 years ago

Here is my function:

`function testsync() {
    const { smarthome } = require('actions-on-google');
    const app = smarthome({
        key: 'AIAAASyBiHC1G4SXefqsbYxUHIawAAAAAAA' // Changed from Actual Key

    });
    // ...
    // New device is added for user
    app.requestSync('1NMWK8AAAEVscJzceSJuLmvGAAA') // Changed from Actual UID
        .then((res) => {
            console.log('Worked', res)
        })
        .catch((res) => {
            console.log('Failed', res)
        });
}`
fabltd commented 4 years ago

Further Testing:

With incorrect UID:

Failed {
  "error": {
    "code": 404,
    "message": "Requested entity was not found.",
    "status": "NOT_FOUND"
  }
}

With Incorrect API KEY:

Failed {
  "error": {
    "code": 400,
    "message": "API key not valid. Please pass a valid API key.",
    "status": "INVALID_ARGUMENT",

To add to the error message. The Sync Event Occurs. Stack driver shows the following error:

SYNC: Request ID 337219942982431064 failed with code: OPEN_AUTH_FAILURE

fabltd commented 4 years ago

To Add account linking works fine. The device is sync is working the device can be controlled from home. The command errors but the sync occurs and home is updated.

Help...

Fleker commented 4 years ago

I was able to have it work fine when using the sample with just a service account key.

fabltd commented 4 years ago

It works but I get the error above along with the OPEN_AUTH_FAILURE in stackdriver. I have no idea why and there seems to be very little debugging ? Where are the permissions it is referring to?

Fleker commented 4 years ago

Open Auth Failure refers to some issue with the account linking.

devunwired commented 4 years ago

This issue has been migrated to the public issue tracker: https://issuetracker.google.com/issues/142048841