Console.log(code)
正常工作,但此后出现错误:
{“错误”:“ invalid_redirect_uri”,“错误说明”:“无法检索访问 令牌:appid /重定向uri /代码验证程序与授权代码不匹配。或授权码已过期。或存在外部成员绑定“”。
`app.use(bodyParser.urlencoded({extended:true}));
app.set("view engine","ejs");
app.use(express.static(__dirname + "/public"));
app.use(methodOverride("_method"));
app.get('/home',function(req,res){
res.render('home');
})
app.get('/profile',function(req,res){
console.log(req.query.code);
var code = req.query.code;
request.post({url:'https://www.linkedin.com/oauth/v2/accessToken',
form:
{grant_type:'authorization_code',code:code,
redirect_uri:'http%3A%2F%2Flocalhost:3000%2Fprofile',
client_id:'value', client_secret:'value'}},
function(err,httpResponse,body){ console.log(httpResponse.body); })`
})
`
答案 0 :(得分:0)
我看到了code:'$code'
,但也许一定是:
code:`${code}`
您的redirect_uri指向本地主机,也许就是问题所在。