我正在创建智能家居集成。我正在尝试设备步骤 - 尝试登录帐户以添加设备。
https://developers.google.com/actions/smarthome/#syncing_devices
我已设置助手以检索OAuth令牌:
这是有效的 - 在我的测试设备上我可以打开:设置>家庭控制>添加设备并查看我的项目。然后我也可以使用OAuth登录。然而,下一步是谷歌然后“助理发送一个action.devices.SYNC意图到你的履行”
来自文档:
用户使用Google智能助理应用设置他们的设备,以便对您的云服务进行身份验证,并且智能助理会收到OAuth令牌。此时,Assistant会向您的履行发送action.devices.SYNC意图,以从您的云基础架构中检索用户设备和功能的初始列表。
实现设置正确:
我的成就如下:
exports.helloWorld = functions.https.onRequest((request, response) => {
const requestId = request.requestId;
if(request.inputs == null) {
console.log("unexpected request " + util.inspect(request, false, null));
console.log("unexpected request id " + requestId);
response.send(400);
return;
}
const userId = request.get("Authorization");
... etc do other stuff then return correct response as a 200
我已检查云功能日志,并调用上述实现。然而,文档说它将发送action.devices.SYNC intent
但它没有。 (因此永远不会超过第一个if
声明。)
它发送了一些我不认识的东西(我没有看到记录,我应该认识到):
(每个请求都应该有一个请求ID - 而且这个请求不会:request id undefined
)
有什么想法吗?
从评论中,这里是stackdriver日志:
{
insertId: "000000-751089a4-XXXX-XXXX-XXXX-f6a11a39b4d5"
labels: {
execution_id: "vXXXXsnaopim"
}
logName: "projects/XXXXX/logs/cloudfunctions.googleapis.com%2Fcloud-functions"
receiveTimestamp: "2018-03-29T13:44:56.577854174Z"
resource: {
labels: {
function_name: "helloWorld"
project_id: "XXXXX"
region: "us-central1"
}
type: "cloud_function"
}
severity: "INFO"
textPayload: "unexpected request IncomingMessage {
_readableState:
ReadableState {
objectMode: false,
highWaterMark: 16384,
buffer: BufferList { head: null, tail: null, length: 0 },
length: 0,
pipes: null,
pipesCount: 0,
flowing: true,
ended: true,
endEmitted: true,
reading: false,
sync: false,
needReadable: false,
emittedReadable: false,
readableListening: false,
resumeScheduled: false,
defaultEncoding: 'utf8',
ranOut: false,
awaitDrain: 0,
readingMore: false,
decoder: null,
encoding: null },
readable: false,
domain: null,
_events: {},
_eventsCount: 0,
_maxListeners: undefined,
socket:
Socket {
connecting: false,
_hadError: false,
_handle:
TCP {
bytesRead: 917,
_externalStream: {},
fd: 12,
reading: true,
owner: [Circular],
onread: [Function: onread],
onconnection: null,
writeQueueSize: 0,
_consumed: true },
_parent: null,
_host: null,
_readableState:
ReadableState {
objectMode: false,
highWaterMark: 16384,
buffer: BufferList { head: null, tail: null, length: 0 },
length: 0,
pipes: null,
pipesCount: 0,
flowing: true,
ended: false,
endEmitted: false,
reading: true,
sync: false,
needReadable: true,
emittedReadable: false,
readableListening: false,
resumeScheduled: false,
defaultEncoding: 'utf8',
ranOut: false,
awaitDrain: 0,
readingMore: false,
decoder: null,
encoding: null },
readable: true,
domain: null,
_events:
{ end:
[ { [Function: g] listener: [Function: onend] },
[Function: socketOnEnd] ],
finish: [Function: onSocketFinish],
_socketEnd: [Function: onSocketEnd],
drain: [ [Function: ondrain], [Function: socketOnDrain] ],
timeout: [Function],
error: [ [Function: socketOnError], [Function: onevent] ],
close:
[ [Function: serverSocketCloseListener],
[Function: onServerResponseClose],
[Function: onevent] ],
data: [Function: socketOnData],
resume: [Function: onSocketResume],
pause: [Function: onSocketPause] },
_eventsCount: 10,
_maxListeners: undefined,
_writableState:
WritableState {
objectMode: false,
highWaterMark: 16384,
needDrain: false,
ending: false,
ended: false,
finished: false,
decodeStrings: false,
defaultEncoding: 'utf8',
length: 0,
writing: false,
corked: 0,
sync: true,
bufferProcessing: false,
onwrite: [Function],
writecb: null,
writelen: 0,
bufferedRequest: null,
lastBufferedRequest: null,
pendingcb: 0,
prefinished: false,
errorEmitted: false,
bufferedRequestCount: 0,
corkedRequestsFree: CorkedRequest { next: null, entry: null, finish: [Function] } },
writable: true,
allowHalfOpen: true,
destroyed: false,
_bytesDispatched: 0,
_sockname: null,
_pendingData: null,
_pendingEncoding: '',
server:
Server {
domain: null,
_events:
{ request:
{ [Function: app]
domain: undefined,
_events: { mount: [Function: onmount] },
_maxListeners: undefined,
setMaxListeners: [Function: setMaxListeners],
getMaxListeners: [Function: getMaxListeners],
emit: [Function: emit],
addListener: [Function: addListener],
on: [Function: addListener],
prependListener: [Function: prependListener],
once: [Function: once],
prependOnceListener: [Function: prependOnceListener],
removeListener: [Function: removeListener],
removeAllListeners: [Function: removeAllListeners],
listeners: [Function: listeners],
listenerCount: [Function: listenerCount],
eventNames: [Function: eventNames],
init: [Function],
defaultConfiguration: [Function],
lazyrouter: [Function],
handle: [Function],
use: [Function: use],
route: [Function],
engine: [Function],
param: [Function],
set: [Function],
path: [Function],
enabled: [Function],
disabled: [Function],
enable: [Function],
disable: [Function],
acl: [Function],
bind: [Function],
checkout: [Function],
connect: [Function],
copy: [Function],
delete: [Function],
get: [Function],
"
timestamp: "2018-03-29T13:44:50.294Z"
}