Sum*_*och 6 javascript authentication slack-api slack
我正在尝试使用 Slack 验证我的应用程序。几天来它工作得很好,但现在它给我带来了一个错误
invalid_code
const requestBody = qs.stringify({
code: code,
redirect_uri: redirect_uri,
client_id: client_id,
client_secret: client_secret
});
await axios
.post(url, requestBody, config).
then(server => console.log(server)).catch(err => console.log(err))
Run Code Online (Sandbox Code Playgroud)
服务器响应:
{ ok: false, error: 'invalid_code' }
我得到的代码就是这种格式。
code=303414024726.805164905556.526d546072e9b2408e0743f42ca3bb5843553a6c3b930b1de2c1e31847b25448
我认为这是 JWT 令牌,但我不确定。
任何帮助,将不胜感激。
小智 0
这就是我让它发挥作用的方式
let slackUrl = `https://slack.com/api/oauth.v2.access`;
let client_id = process.env.SLACK_CLIENT_ID;
let client_secret = process.env.SLACK_CLIENT_SECRET;
let details = {
code,
client_id,
client_secret
}
var formBody = [];
for (var property in details) {
var encodedKey = encodeURIComponent(property);
var encodedValue = encodeURIComponent(details[property]);
formBody.push(encodedKey + "=" + encodedValue);
}
formBody = formBody.join("&");
const _headers = {
'Content-Type': 'application/x-www-form-urlencoded'
};
let config = {
method: 'POST',
url: slackUrl,
data: formBody,
headers: _headers
};
let installation = await axios(config);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4458 次 |
| 最近记录: |