Console.log(code)
工作正常,但之后我收到错误:
{"error":"invalid_redirect_uri","error_description":"Unable to retrieve access token: appid/redirect uri/code verifier does not match authorization code. Or authorization code expired. Or external member binding exists"}.
`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); })`
})
`
最佳答案
我看到代码:'$code'
但也许它必须是:
code:`${code}`
你的redirect_uri指向本地主机,也许这就是问题所在。
关于javascript - 无法生成 linkedIn 的访问 token ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51492409/