因此,我正在编写一个discord机器人,该机器人基本上使我为一堆不同的命令制作的API连接起来。不幸的是,我坚持这一看跌期权要求,并且指出了错误所在。 该请求似乎没有发送我在标头中设置的身份验证密钥。我检查了API日志,并且auth中间件拒绝了该请求,因为没有提供密钥。我将不胜感激。
collector.on('collect', async () => {HERE})
中。let updatedUser = await axios.put(
`https://API-URL-GOES-HERE/api/users/${username}/loaChange`,
{
headers: {
auth:
'AUTH-KEY-GOES-HERE'
}
}
);
已收到失败的标题:
{
host: 'API-URL-HERE.herokuapp.com',
connection: 'close',
accept: 'application/json, text/plain, */*',
'content-type': 'application/json;charset=utf-8',
'user-agent': 'axios/0.19.0',
'x-request-id': 'REQID',
'x-forwarded-for': 'IPADRESS',
'x-forwarded-proto': 'https',
'x-forwarded-port': '443',
via: '1.1 vegur',
'connect-time': '2',
'x-request-start': '1577766826940',
'total-route-time': '5',
'content-length': '194'
}
成功的请求:
let initialUser = await axios.get(
`https://API-URL-GOES-HERE/api/users/${username}`,
{
headers: {
auth:
'AUTH-KEY-GOES-HERE'
}
}
);
成功获得的标题:
{
host: 'API-URL-HERE.herokuapp.com',
connection: 'close',
accept: 'application/json, text/plain, */*',
auth: 'AUTH-KEY-HERE',
'user-agent': 'axios/0.19.0',
'x-request-id': 'REQID',
'x-forwarded-for': 'IPADDRESS',
'x-forwarded-proto': 'https',
'x-forwarded-port': '443',
via: '1.1 vegur',
'connect-time': '0',
'x-request-start': '1577766773203',
'total-route-time': '0'
}
<<因此,我正在编写一个discord机器人,该机器人基本上使我为一堆不同的命令制作的API连接起来。不幸的是,我坚持这一看跌期权要求,并且指出了错误所在。 ...
{ headers: {"Authorization" : `Bearer ${AUTH-KEY-GOES-HERE}`} }