Node.js 使用请求补丁从ElectronJS更新Discord Profil图片

Node.js 使用请求补丁从ElectronJS更新Discord Profil图片,node.js,api,electron,discord,Node.js,Api,Electron,Discord,我正在尝试将一个应用程序编码为Electron JS,以允许用户在多个应用程序上同时更改其个人资料图片。 为此,我使用每个平台的API。 对于Twitter来说,它工作正常,但我在不和谐的层面上阻止了它。 我可以在配置文件上发出GET请求,但我不能执行:PATCH/users/@me 我不知道是不是这个代币没有提供足够的能量,因为我只是在我的应用程序中请求身份作为许可。 我试图在真与假之间传递JSON, 添加内容类型,但我仍然有相同的答案:{code:0,message:'401:Unauth

我正在尝试将一个应用程序编码为Electron JS,以允许用户在多个应用程序上同时更改其个人资料图片。 为此,我使用每个平台的API。 对于Twitter来说,它工作正常,但我在不和谐的层面上阻止了它。 我可以在配置文件上发出GET请求,但我不能执行:PATCH/users/@me

我不知道是不是这个代币没有提供足够的能量,因为我只是在我的应用程序中请求身份作为许可。 我试图在真与假之间传递JSON, 添加内容类型,但我仍然有相同的答案:{code:0,message:'401:Unauthorized'}

function postDiscord(image) {
    const imageDataURI = require('image-data-uri')
    let {token} = store.get('discordToken') //get stored token

    imageDataURI.encodeFromFile(image)
    .then(res => {
        request({
            method: 'PATCH',
            url: 'https://discordapp.com/api/v6/users/@me',
            headers: {
               'Authorization': 'Bearer '+token,
               'User-Agent': 'someBot (site, v0.1)'
            },
            body: {
                'avatar': res
            },
            json: true
            }, function(err, res) {
                if(err) {
                  console.error(err);
                } else {
                    console.log(res.body)
                }

            }
        );
    })
}
{代码:0,消息:“401:未经授权”}

指的是不一致:
function postDiscord(image) {
    const imageDataURI = require('image-data-uri')
    let {token} = store.get('discordToken') //get stored token

    imageDataURI.encodeFromFile(image)
    .then(res => {
        request({
            method: 'PATCH',
            url: 'https://discordapp.com/api/v6/users/@me',
            headers: {
               'Authorization': 'Bearer '+token,
               'User-Agent': 'someBot (site, v0.1)'
            },
            body: {
                'avatar': res
            },
            json: true
            }, function(err, res) {
                if(err) {
                  console.error(err);
                } else {
                    console.log(res.body)
                }

            }
        );
    })
}
无法使用Oauth://p>上载新图片,这与不一致有关: 无法使用Oauth上载新图片:/