【发布时间】:2021-08-27 07:54:30
【问题描述】:
当我测试向谷歌报告智能家居设备状态时,我收到以下错误:
"error": {
"code": 403,
"message": "The request is missing a valid API key.",
"status": "PERMISSION_DENIED"}
我按照此指南https://developers.google.com/assistant/smarthome/develop/report-state#service-account-key 获取服务帐户密钥。
HttpEntity entity = httpRequest("https://www.googleapis.com/auth/homegraph", jwt, params, "application/x-www-form-urlencoded");
这是我获取令牌的代码。
HttpEntity entity = httpRequest("https://homegraph.googleapis.com/v1/devices:reportStateAndNotification", token, params, "application/json");
这是我报告状态的代码。
我想知道令牌是无效还是有什么问题。
另外,这是否与agentUserId有关。
{"requestId": "123ABC","agentUserId": "user-123","payload": {
"devices": {
"states": {
"light-123": {
"on": true
}
}
}
} }
【问题讨论】: