# passport-hubspot-auth

> Passport strategy for authenticating with Hubspot.

Latest version **1.0.5** (published 2022-12-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install passport-hubspot-auth
pnpm add passport-hubspot-auth
yarn add passport-hubspot-auth
bun add passport-hubspot-auth
```

## 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.5 |
| Published | 2022-12-09 |
| First published | 2019-08-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 15.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | John Barlow |
| Maintainers | jnbarlow |
| Keywords | hubspot, passport, auth, authentication, nodejs |

## Links

- npm: https://www.npmjs.com/package/passport-hubspot-auth
- Repository: https://github.com/jnbarlow/passport-hubspot-auth
- Homepage: https://github.com/jnbarlow/passport-hubspot-auth#readme
- Issues: https://github.com/jnbarlow/passport-hubspot-auth/issues
- npm.io page: https://npm.io/package/passport-hubspot-auth

## Dependencies (2)

- [pkginfo](https://npm.io/package/pkginfo.md) 0.4.x
- [passport-oauth](https://npm.io/package/passport-oauth.md) ~1.0.0

## Alternatives

- [@clerk/clerk-expo](https://npm.io/package/@clerk/clerk-expo.md) — 133.6K weekly downloads
- [@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
- [@oxyhq/services](https://npm.io/package/@oxyhq/services.md) — 2.3K weekly downloads
- [@luigi-project/plugin-auth-oauth2](https://npm.io/package/@luigi-project/plugin-auth-oauth2.md) — 2.3K weekly downloads

## Recent versions

- 1.0.5 (latest) — 2022-12-09
- 1.0.4 — 2022-12-09
- 1.0.3 — 2021-12-20
- 1.0.2 — 2019-11-12
- 1.0.1 — 2019-08-30
- 1.0.0 — 2019-08-13

## README

[![CircleCI](https://circleci.com/gh/jnbarlow/passport-hubspot-auth.svg?style=shield)](https://circleci.com/gh/jnbarlow/passport-hubspot-auth)

# Passport-Hubspot-Auth

[Passport](http://passportjs.org/) strategies for authenticating with [Hubspot](http://www.hubspot.com/)
using OAuth 2.0.

This module lets you authenticate using HubSpot credentials in your Node.js applications.
By plugging into Passport, HubSpot 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-hubspot-auth

## Usage of OAuth 2.0

#### Configure Strategy

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

```javascript
var HubSpotStrategy = require( 'passport-hubspot-auth' ).Strategy;

passport.use(new HubSpotStrategy({
    clientID:     HUBSPOT_CLIENT_ID,
    clientSecret: HUBSPOT_CLIENT_SECRET,
    callbackURL: "http://yourdomain:3000/auth/hubspot/callback",
    passReqToCallback   : true
  },
  function(request, accessToken, refreshToken, profile, done) {
    // Information is sent back here.
  }
));
```
Conversely, if you don't want the request to be available, omit `passReqToCallback` or set it to false

```javascript
var HubSpotStrategy = require( 'passport-hubspot-auth' ).Strategy;

passport.use(new HubSpotStrategy({
    clientID:     HUBSPOT_CLIENT_ID,
    clientSecret: HUBSPOT_CLIENT_SECRET,
    callbackURL: "http://yourdomain:3000/auth/hubspot/callback",
    passReqToCallback   : false
  },
  function(accessToken, refreshToken, profile, done) {
    // Information is sent back here.
  }
));
```

```javascript
var HubSpotStrategy = require( 'passport-hubspot-auth' ).Strategy;

passport.use(new HubSpotStrategy({
    clientID:     HUBSPOT_CLIENT_ID,
    clientSecret: HUBSPOT_CLIENT_SECRET,
    callbackURL: "http://yourdomain:3000/auth/hubspot/callback",
  },
  function(accessToken, refreshToken, profile, done) {
    // Information is sent back here.
  }
));
```

#### Authenticate Requests

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

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

```javascript
app.get('/auth/hubspot',
  passport.authenticate('google', { scope: 'contacts content' }
));

app.get( '/auth/hubspot/callback',
	passport.authenticate( 'hubspot', {
		successRedirect: '/auth/hubspot/success',
		failureRedirect: '/auth/hubspot/failure'
}));
```

#### Profile Response

```
profile { 
    token: '<access token>',
    user: '<hubspot username>',
    hub_domain: '<hubspot instance>',
    scopes: [ <array of scopes> ],
    hub_id: ########,
    app_id: ######,
    expires_in: #####, //seconds from now
    user_id: ########,
    token_type: 'access',
    provider: 'hubspot' 
}
```

## Credits
  
  - [John Barlow](http://github.com/jnbarlow)
  - [Jared Hanson](http://github.com/jaredhanson) (original author of passport-hubspot-oauth2)
  - [passport-hubspot-oauth2](https://www.npmjs.com/package/passport-hubspot-oauth2) - abandoned project that this was based upon.

## License

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

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