Я отправляю запрос о состоянии отчета в моем onExecute
обработчике. Это не работает с:
io.grpc.StatusRuntimeException: UNAUTHENTICATED: Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
at io.grpc.stub.ClientCalls.toStatusRuntimeException(ClientCalls.java:233)
at io.grpc.stub.ClientCalls.getUnchecked(ClientCalls.java:214)
at io.grpc.stub.ClientCalls.blockingUnaryCall(ClientCalls.java:139)
at com.google.home.graph.v1.HomeGraphApiServiceGrpc$HomeGraphApiServiceBlockingStub.reportStateAndNotification(HomeGraphApiServiceGrpc.java:425)
at com.google.actions.api.smarthome.SmartHomeApp.reportState(SmartHomeApp.kt:132)
[snip]
Я не понимаю, как это возможно, поскольку я использую SmartHomeApp для выполнения запроса, тот же SmartHomeApp, который получает синхронизацию, запрос, выполнение, отключение. Вот мой код:
var state = new HashMap();
state.put("openPercent", 50); // etc
SmartHomeApp app = ... // this is what received the onExecute
app.reportState(ReportStateAndNotificationRequest.newBuilder()
.setRequestId(request.requestId) // onExecute requestId
.setAgentUserId(userId) // hardcoded user
.setPayload(StateAndNotificationPayload.newBuilder()
.setDevices(ReportStateAndNotificationDevice.newBuilder()
.setStates(Struct.newBuilder()
// toValue converts the state to a protobuf value, see data below
.putFields("kitchenDoor", UtilProtoBuf.toValue(state))
.build()
).build()
).build()
).build());
toString
для ReportStateAndNotificationRequest
, чтобы вы могли видеть данные:
request_id: "16744804305948869781"
agent_user_id: "123"
payload {
devices {
states {
fields {
key: "kitchenDoor"
value {
struct_value {
fields {
key: "openPercent"
value {
number_value: 50.0
}
}
}
}
}
}
}
}