GDMS (Grandstream API) POST 请求与 axios

问题描述

我正在尝试向 GDMS api 发出 POST 请求。 我不断收到错误代码:4000,这意味着“签名不存在”

我先获取令牌并返回axios.create()

exports.client = async () =>{
    return new Promise((resolve =>{
        axios.get('https://www.gdms.cloud/oapI/Oauth/token',{
            params:{
                username: username,password: password,grant_type: grant_type,client_id: client_id,client_secret: client_secret
            }
        }).then(res=>{
            let client = axios.create({
                baseURL: 'https://www.gdms.cloud/oapi/v1.1.0',headers: {'authorization': `bearer${res.data.access_token}`}
            })
            return resolve(client)
        }).catch(error=>{
            console.log(error.message)
            return resolve(false)
        })
    }))
}

效果很好。

然后我像这样调用端点 /sip/servers/list

等待 gdms.sipServers.list(客户端)

exports.list = async (client) =>{
    return new Promise(resolve => {
        let timestamp = new Date().toISOString()
        client.post('/sip/server/list',{
            timestamp: timestamp,signature: sha256(`&timestamp=${timestamp}&`)
        }).then(res=>{
            console.log(res.data)
            return resolve(res.data)
        }).catch(error=>{
            console.log(error.message)
            return resolve(false)
        })
    })
}

但我一直收到同样的错误“签名不存在”

任何帮助将不胜感激。 这是签名文件 https://doc.grandstream.dev/GDMS-API/EN/#api-157061470296601000002

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)