Google Chat API(G Suite):请求包含无效的参数(Node JS) [英] Google Chat API (G Suite): Request contains an invalid argument (Node JS)

查看:124
本文介绍了Google Chat API(G Suite):请求包含无效的参数(Node JS)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

const { google } = require('googleapis')
const privatekey = require('./a.json')
const scopes = ['https://www.googleapis.com/auth/chat.bot'];

const a = async () => {
    try {
        const jwtClient = new google.auth.JWT(
            privatekey.client_email,
            null,
            privatekey.private_key,
            scopes,
            'adminEmail@org.com'
        );
        await jwtClient.authorize();
        const chat = google.chat({ version: 'v1', auth: jwtClient });
        const res = await chat.spaces.messages.get({name:'spaces/XXX/messages/XX.XX'})
        console.log(res)
    }
    catch(e) {
        console.log(e)
    }
}
a()

错误:请求包含无效的参数

Error: Request contains an invalid argument

我找不到无效的参数

预先感谢

推荐答案

许多环聊API请求都需要使用服务帐户

  • 您可以在文档中进行咨询.请求类型受到影响
  • 对于需要使用服务帐户的请求-这意味着服务帐户代表其自身行事
  • 冒名顶替是指服务帐户代表另一个用户行事
  • 因此,对于需要由服务帐户执行的请求,不允许进行模拟操作
  • 还请注意, https://www.googleapis.com/auth/chat.bot 是服务帐户在没有域范围内委派的情况下使用的范围
  • 用户或模拟服务帐户需要使用范围 https://www.googleapis.com/auth /chat 代替-另请参见此处
  • 最后但并非最不重要的是,不允许聊天机器人删除其他用户的消息
  • Many Hangouts API request require the usage of a service account

    • You can consult in the documentation which type of requests are affected
    • For the requests requiring the usage of a service account - it is meant that the service account acts on its own behalf
    • Impersonation means that the service account acts on behalf of another user
    • Thus, impersonation is not allowed for requests that need to be carried out by a service account
    • Also mind that https://www.googleapis.com/auth/chat.bot is the scope to be used by the service account without domain-wide delegation
    • Users or impersonated service accounts need to use the scope https://www.googleapis.com/auth/chat instead - see also here
    • Last but not least, chat bots are not allowed to delete messages of other users
    • 这篇关于Google Chat API(G Suite):请求包含无效的参数(Node JS)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆