# passport-linkedin

> LinkedIn authentication strategy for Passport.

Latest version **1.0.0** (published 2015-09-14) · 0 weekly downloads

## Install

```sh
npm install passport-linkedin
pnpm add passport-linkedin
yarn add passport-linkedin
bun add passport-linkedin
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2015-09-14 |
| First published | 2011-11-01 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 0.4.0 |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 141 |
| Author | Jared Hanson |
| Maintainers | jaredhanson |
| Keywords | passport, linkedin, auth, authn, authentication, identity |

## Links

- npm: https://www.npmjs.com/package/passport-linkedin
- Repository: https://github.com/jaredhanson/passport-linkedin
- Issues: http://github.com/jaredhanson/passport-linkedin/issues
- npm.io page: https://npm.io/package/passport-linkedin

## Dependencies (1)

- [passport-oauth1](https://npm.io/package/passport-oauth1.md) 1.x.x

## Alternatives

- [@pothos/plugin-authz](https://npm.io/package/@pothos/plugin-authz.md) — 12.4K weekly downloads
- [@bounded-sh/client](https://npm.io/package/@bounded-sh/client.md) — 3.2K weekly downloads
- [@luigi-project/plugin-auth-oauth2](https://npm.io/package/@luigi-project/plugin-auth-oauth2.md) — 2.3K weekly downloads
- [@nocobase/plugin-verification](https://npm.io/package/@nocobase/plugin-verification.md) — 2.0K weekly downloads
- [escher-request](https://npm.io/package/escher-request.md) — 545 weekly downloads

## Recent versions

- 1.0.0 (latest) — 2015-09-14
- 0.1.3 — 2013-02-10
- 0.1.2 — 2012-04-30
- 0.1.1 — 2012-02-21
- 0.1.0 — 2011-11-01

## README

# Passport-LinkedIn

[Passport](http://passportjs.org/) strategy for authenticating with [LinkedIn](http://www.linkedin.com/)
using the OAuth 1.0a API.

This module lets you authenticate using LinkedIn in your Node.js applications.
By plugging into Passport, LinkedIn authentication can be easily and
unobtrusively integrated into any application or framework that supports
[Connect](http://www.senchalabs.org/connect/)-style middleware, including
[Express](http://expressjs.com/).

## Install

    $ npm install passport-linkedin

## Usage

#### Configure Strategy

The LinkedIn authentication strategy authenticates users using a LinkedIn
account and OAuth tokens.  The strategy requires a `verify` callback, which
accepts these credentials and calls `done` providing a user, as well as
`options` specifying a consumer key, consumer secret, and callback URL.

    passport.use(new LinkedInStrategy({
        consumerKey: LINKEDIN_API_KEY,
        consumerSecret: LINKEDIN_SECRET_KEY,
        callbackURL: "http://127.0.0.1:3000/auth/linkedin/callback"
      },
      function(token, tokenSecret, profile, done) {
        User.findOrCreate({ linkedinId: profile.id }, function (err, user) {
          return done(err, user);
        });
      }
    ));

#### Authenticate Requests

Use `passport.authenticate()`, specifying the `'linkedin'` strategy, to
authenticate requests.

For example, as route middleware in an [Express](http://expressjs.com/)
application:

    app.get('/auth/linkedin',
      passport.authenticate('linkedin'));
    
    app.get('/auth/linkedin/callback', 
      passport.authenticate('linkedin', { failureRedirect: '/login' }),
      function(req, res) {
        // Successful authentication, redirect home.
        res.redirect('/');
      });

#### Extended Permissions

If you need extended permissions from the user, the permissions can be requested
via the `scope` option to `passport.authenticate()`.

For example, this authorization requests permission to the user's basic profile
and email address:

    app.get('/auth/linkedin',
      passport.authenticate('linkedin', { scope: ['r_basicprofile', 'r_emailaddress'] }));

#### Profile Fields

The LinkedIn profile is very rich, and may contain a lot of information.  The
strategy can be configured with a `profileFields` parameter which specifies a
list of fields your application needs.  For example, to fetch the user's ID, name,
email address, and headline, configure strategy like this.

    passport.use(new LinkedInStrategy({
        // clientID, clientSecret and callbackURL
        profileFields: ['id', 'first-name', 'last-name', 'email-address', 'headline']
      },
      // verify callback
    ));

## Examples

For a complete, working example, refer to the [login example](https://github.com/jaredhanson/passport-linkedin/tree/master/examples/login).

## Tests

    $ npm install --dev
    $ make test

[![Build Status](https://secure.travis-ci.org/jaredhanson/passport-linkedin.png)](http://travis-ci.org/jaredhanson/passport-linkedin)

## Credits

  - [Jared Hanson](http://github.com/jaredhanson)

## License

[The MIT License](http://opensource.org/licenses/MIT)

Copyright (c) 2011-2013 Jared Hanson <[http://jaredhanson.net/](http://jaredhanson.net/)>

---
_Source: https://npm.io/package/passport-linkedin · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
