Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/377.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何使用discord oauth获取公会信息?_Javascript_Oauth 2.0_Discord - Fatal编程技术网

Javascript 如何使用discord oauth获取公会信息?

Javascript 如何使用discord oauth获取公会信息?,javascript,oauth-2.0,discord,Javascript,Oauth 2.0,Discord,如何获取特定的公会信息?如果我删除guilds.id,它会工作,但它只返回我所在的所有行会的列表。 使用discord api获取和更新公会信息的正确方法是什么 这是我获取访问令牌的方式: const key = req.query.code, options = { href:`https://discordapp.com/api/oauth2/token`, code : `code=${key}`,

如何获取特定的
公会信息
?如果我删除guilds.id,它会工作,但它只返回我所在的所有行会的列表。
使用discord api获取和更新公会信息的正确方法是什么

这是我获取访问令牌的方式:

const key   =  req.query.code,
options     =  {
                  href:`https://discordapp.com/api/oauth2/token`,  
                  code : `code=${key}`,
                  grant_type : grant_type=authorization_code`,
                  redirect_uri :`redirect_uri=${redirect}` 
                 };

    request({
        uri: `${options.href}?${options.grant_type}&${options.code}&${options.redirect_uri}`,
        method: 'POST',
        headers: {
            Authorization: `Basic ${creds}`,
        }
    }, (err,response, body) => {
       if(err) return console.log(err);
       console.log(body) // console log access_token
    })
使用access\u令牌发出请求

//My get request options 
    const options =  { 
            url: `https://discordapp.com/api/guilds/${guilds.id}`,
            method: 'GET',
            json: true,
            headers: {
            authorization: `${token_type} ${access_token}`}
        }

//Both of these options arent working
//token_type = bot
//token_type = Bearer 
给了我
401:未经授权的

我的访问令牌范围是:

`identify email guilds guilds.join gdm.join rpc connections`

我认为它只是
/api/guilds/${guilds.id}
它显示了
401:Unauthorized
@Sashais您的
token\u类型
bot或bearerit,s bearer@sasatary使用您的bot令牌获取上述url,并将
bot
作为令牌类型