【问题标题】:Discord Profil Picture Update from ElectronJS using request PATCH使用请求 PATCH 从 Electron JS 更新 Discord 个人资料图片
【发布时间】:2019-12-16 11:09:00
【问题描述】:

我正在尝试将一个应用程序编码到 Electron JS 中,以允许该人同时在多个应用程序上更改他们的个人资料图片。 为此,我使用每个平台的 API。 对于 Twitter,它可以正常工作,但我在 Discord 级别阻止。 我可以在个人资料上发出 GET 请求,但我不能:PATCH/users/@me https://discordapp.com/developers/docs/resources/user#modify-current-user

我不知道是否是令牌没有提供足够的权力,因为我只要求身份作为我的应用程序的权限。 我试图在真假之间传递 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)
                }

            }
        );
    })
}

{code: 0, message: '401: Unauthorized'}

【问题讨论】:

    标签: node.js api electron discord


    【解决方案1】:

    参考 Discord :https://github.com/discordapp/discord-api-docs/issues/1057 无法使用 Oauth 上传新图片:/

    【讨论】:

      猜你喜欢
      • 2019-04-29
      • 2021-09-23
      • 2019-10-25
      • 1970-01-01
      • 2011-02-14
      • 1970-01-01
      • 2013-04-13
      • 1970-01-01
      • 2021-08-13
      相关资源
      最近更新 更多