Actions on google 提供未经授权的推送通知,即400
以下是我所遵循的设置: 我遵循了中提到的内容: 这是用于发送通知的代码: 我已经对userId进行了硬编码,这是我在请求用户许可后的最后一步意图的后端实现中获得的userIdActions on google 提供未经授权的推送通知,即400,actions-on-google,http-status-code-400,Actions On Google,Http Status Code 400,以下是我所遵循的设置: 我遵循了中提到的内容: 这是用于发送通知的代码: 我已经对userId进行了硬编码,这是我在请求用户许可后的最后一步意图的后端实现中获得的userId const google = require('googleapis'); const key = require("./service-account-key.json"); var jwtClient = new google.auth.JWT( key.client_email, null, key.priva
const google = require('googleapis');
const key = require("./service-account-key.json");
var jwtClient = new google.auth.JWT(
key.client_email, null, key.private_key,
['https://www.googleapis.com/auth/actions.fulfillment.conversation'],
null
);
jwtClient.authorize(function (err, tokens) {
var notif = {
userNotification: {
title: "This is a test reply",
},
target: {
userId: 'ABwppHE75K2ZVr00a7EcCT_4hv00fck7aFtdR7PmO_w3U3j9w1b3uCjyCoStVAHSgv5LL3Swup9RmkZ-',
intent: 'doctor_reply'
}
}
console.log(JSON.stringify(tokens) + "\n" + JSON.stringify(notif));
request.post('https://actions.googleapis.com/v2/conversations:send', {
'auth': {
'bearer': tokens.access_token
},
'json': true,
'body': { 'customPushMessage': notif, 'isInSandbox': true}
}, function(err,httpResponse,body) {
console.log("notification sent");
console.log(err, body, httpResponse.statusCode + ': ' + httpResponse.statusMessage)
});
});
有没有人面临过类似的问题 因此,在调试之后&通过反复试验。我意识到我是在IOS手机上试用的&由于某些原因,api给出了这个错误,因为IOS助手版本。我假设,因为他们在文档中说它仍处于测试阶段,他们可能没有为ios用户启用它
当我在android手机上运行google assistant测试构建时,我立即收到了200个通知,通知效果非常好。你能发送你的应用程序发送的json来发送推送通知吗。。。
const google = require('googleapis');
const key = require("./service-account-key.json");
var jwtClient = new google.auth.JWT(
key.client_email, null, key.private_key,
['https://www.googleapis.com/auth/actions.fulfillment.conversation'],
null
);
jwtClient.authorize(function (err, tokens) {
var notif = {
userNotification: {
title: "This is a test reply",
},
target: {
userId: 'ABwppHE75K2ZVr00a7EcCT_4hv00fck7aFtdR7PmO_w3U3j9w1b3uCjyCoStVAHSgv5LL3Swup9RmkZ-',
intent: 'doctor_reply'
}
}
console.log(JSON.stringify(tokens) + "\n" + JSON.stringify(notif));
request.post('https://actions.googleapis.com/v2/conversations:send', {
'auth': {
'bearer': tokens.access_token
},
'json': true,
'body': { 'customPushMessage': notif, 'isInSandbox': true}
}, function(err,httpResponse,body) {
console.log("notification sent");
console.log(err, body, httpResponse.statusCode + ': ' + httpResponse.statusMessage)
});
});