您好我已经实现了LINE API模块并且可以成功重定向到回调网址,但问题是它不会在回调页面中输出res.send(token_response)。无论如何我可以在回调页面中呈现它吗?
这是我的代码。
"use strict";
var express = require('express');
var app = express();
const line_login = require("line-login");
const login = new line_login({
channel_id: 118, // not real id
channel_secret: "6907", //edited it for security
callback_url: "/m.html",
scope: "openid profile",
prompt: "consent",
bot_prompt: "normal"
});
// here you set that all templates are located in `/views` directory
//app.set('views', __dirname + '/views');
// here you set that you're using `ejs` template engine, and the
// default extension is `ejs`
app.set('view engine', 'ejs');
app.use('/css', express.static(__dirname + '/public'));
app.use(express.static(__dirname + '/public'));
app.get('/', function(req, res) {
res.render('pages/index');
});
app.listen(process.env.PORT || 5000, () => {
console.log(`server is listening to ${process.env.PORT || 5000}...`);
});
// Specify the path you want to start authorization.
app.use("/", login.auth());
// Specify the path you want to wait for the callback from LINE authorization endpoint.
app.use("/callbackurl", login.callback((req, res, next, token_response) => {
// Success callback
res.send(token_response);
},(req, res, next, error) => {
// Failure callback
res.status(400).json(error);
}));