有没有人能够让 google-api-nodejs-client 成功插入片刻?
无论我尝试什么,我都会收到一个通用的 400“无效值”错误,但无法缩小无效值的范围,因为API Explorer也不起作用。
是因为缺少 data-requestvisibleactions 参数吗?我正在使用 passport.jsrequire('passport-google-oauth').OAuth2Strategy
来处理 oauth 访问,这部分工作正常,但我不知道如何将 requestvisibleactions 合并到 oauth 请求流中,因为这绝对不是来自客户端表单。
这是我正在尝试做的一个片段(使用最新版本的googleapis
v1.0.2):
var google = require('googleapis')
var auth = new google.auth.OAuth2()
auth.setCredentials({
'access_token': user.token
})
google.plus('v1').moments.insert({
collection: 'vault',
userId: 'me',
debug: true,
resource: {
type: "http://schemas.google.com/AddActivity",
target: {
type: "http://schema.org/CreativeWork",
url: "...omitted...",
image: "...omitted...",
description: "test",
name: "test"
}
},
auth: auth
}, function (err, response) {
if (err) {
console.error(err)
res.send(err.code, err)
} else {
console.log(response)
res.send(200)
}
})
ref 1(过时的 wrt 的旧版本googleapis
)
ref 2(客户端,其中使用 data-requestvisibleactions 更明显)