node-linkedin coonection issue

时间:2016-04-03 09:50:19

标签: node.js linkedin linkedin-api

我在尝试使用node-linkedin实现connexion的例子时遇到了问题。

我总是收到此错误:{ errorCode: 0, message: 'Invalid access token.', requestId: 'IN32C163DK', status: 401, timestamp: 1459554255669 }

这是我的代码:

var nodemailer = require('nodemailer');

var Linkedin = require('node-linkedin')('app-id', 'secret', 'callback');

router.get('/linkedin', function(req, res) {
console.log("hello linkedin");
var linkedin = Linkedin.init('my_access_token');
linkedin.companies_search.name('facebook', 1, function(err, company) {
console.log(company);
name = company.companies.values[0].name;
desc = company.companies.values[0].description;
industry = company.companies.values[0].industries.values[0].name;
city = company.companies.values[0].locations.values[0].address.city;
websiteUrl = company.companies.values[0].websiteUrl;
});
});

此处包的链接:https://github.com/ArkeologeN/node-linkedin

你可以帮我吗?

由于

1 个答案:

答案 0 :(得分:0)

我解决了这个问题。

router.get('/linkedin', function(req, res) {

Linkedin.auth.getAccessToken(res, req.query.code, req.query.state, function(err, results) {
    if ( err )
        return console.error(err);

    var linkedin = Linkedin.init(results.access_token || results.accessToken);

});

linkedin.companies_search.name('facebook', 1, function(err, company) {
console.log(company);
name = company.companies.values[0].name;
console.log(name);
});

});

});