ArkeologeN / node-linkedin

LinkedIn 2.0 wrapper in Node.js
MIT License
163 stars 78 forks source link

authorize() not defined #2

Closed sproutly closed 10 years ago

sproutly commented 10 years ago

When I follow the Readme and implment the following method:

app.get('/oauth/linkedin', function(req, res) {
    // This will ask for permisssions etc and redirect to callback url.
    linkedin.authorize();
});

I get the error:

TypeError: Object #<Object> has no method 'authorize'

Since I can't OAuth an user, I can't the use the rest of the wrapper

ArkeologeN commented 10 years ago

Added 5589500a225acb27f7c9b74d11c7792db2f04267

sproutly commented 10 years ago

the commit didn't seem to work

ArkeologeN commented 10 years ago

I'm not sure what problem you're facing. Can you please show your stack trace or snippet what you're doing?

Just a quick, do this:

var Linkedin = require('node-linkedin')('api', 'secret', 'callback');
// Example if using express
app.get('/oauth/linkedin', function(req, res) {
       Linkedin.auth.authorize(res, ['r_basicprofile', 'r_fullprofile', 'r_emailaddress', 'r_network', 'r_contactinfo', 'rw_nus', 'rw_groups', 'w_messages']);
});

app.get('/oauth/linkedin/callback', function(req, res) {
    Linkedin.auth.getAccessToken(res, req.query.code, function(err, results) {
        if ( err )
            return console.error(err);

        /**
         * Results have something like:
         * {"expires_in":5184000,"access_token":". . . ."}
         */

        console.log(results);
        return res.redirect('/');
    });
});

Also, don't forget to update your version to 1.0.4.