【发布时间】:2016-12-24 06:16:45
【问题描述】:
我正在尝试为 slack 开发一个应用程序。 我想通过松弛按钮获取代码参数以响应 oauth 流,但我不知道如何获取参数。
事实上,我首先发送了按钮,然后有人可以单击它并在其松弛通道上实现应用程序,然后 oauth 流将我重定向到一个新网页,该网页的 url 是 https://www.myappname.com/oauth/?code=[parameter我不想得到]&state=
问题是我获取代码参数的方法没有等待重定向。
这是我的代码:
var app = express();
var router = express.Router();
var port = process.env.PORT || 5000;
app.use('/', router);
recupCode = function(req, res, next){
console.log(req.params);
console.log('cb1 : le code est récupéré');
res.end();
};
//Fonctions de Callback
boutonSlack = function(req, res) {
res.send('<a href="https://slack.com/oauth/authorize?scope=incoming-webhook,'
+'&client_id='+process.env.CLIENT_ID+'">'
+'<img alt="Add to Slack" height="40" width="139"'
+'src="https://platform.slack-edge.com/img/add_to_slack.png" '
+'srcset="https://platform.slack-edge.com/img/add_to_slack.png 1x, '
+'https://platform.slack-edge.com/img/add_to_slack@2x.png 2x" /></a>');
console.log('cb0:le bouton slack s\'affiche');
router.get('/oauth/',recupCode);
};
router.get('/',boutonSlack);
app.listen(port, function () {
console.log('Ready');
});
【问题讨论】:
标签: javascript node.js oauth slack