2016-04-03 79 views
0

我在嘗試使用node-linkedin實施connexion示例時遇到問題。node-linkedin連接問題

我總是得到這樣的錯誤:{ 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

你能幫我對嗎?

謝謝

+0

您是否正確傳遞了您從鏈接中收到的訪問權限?你是否遵循了https://developer.linkedin.com/docs/oauth2中給出的過程? –

回答

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); 
}); 

}); 

});