# bell

> Third-party login plugin for hapi

Latest version **10.0.0** (published 2019-03-05) · BSD-3-Clause license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install bell
pnpm add bell
yarn add bell
bun add bell
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 10.0.0 |
| Published | 2019-03-05 |
| First published | 2014-06-02 |
| Weekly downloads | 0 |
| License | BSD-3-Clause |
| TypeScript types | separate (@types/bell) |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 68.1 KB |
| Known vulnerabilities | 0 (+3 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 615 |
| Maintainers | adrivanhoudt, bell, hueniverse, marsup, nlf, wyatt |
| Keywords | hapi, login, authentication, oauth, plugin, auth0, arcgisonline, bitbucket, dropbox, facebook, fitbit, foursquare, github, gitlab, google, instagram, medium, linkedin, live, meetup, nest, phabricator, office365, okta, reddit, spotify, tumblr, twitter, vk, wordpress, yahoo |

## Links

- npm: https://www.npmjs.com/package/bell
- Repository: https://github.com/hapijs/bell
- Homepage: https://github.com/hapijs/bell#readme
- Issues: https://github.com/hapijs/bell/issues
- npm.io page: https://npm.io/package/bell

## Dependencies (6)

- [joi](https://npm.io/package/joi.md) 14.x.x
- [boom](https://npm.io/package/boom.md) 7.x.x
- [hoek](https://npm.io/package/hoek.md) 6.x.x
- [wreck](https://npm.io/package/wreck.md) 14.x.x
- [bounce](https://npm.io/package/bounce.md) 1.x.x
- [cryptiles](https://npm.io/package/cryptiles.md) 4.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

- 10.0.0 (latest) — 2019-03-05
- 9.5.0 — 2019-02-26
- 9.4.0 — 2018-11-10
- 9.3.1 — 2018-05-29
- 9.3.0 — 2018-04-03
- 9.2.0 — 2018-04-02
- 9.1.0 — 2018-02-26
- 9.0.0 — 2018-02-26
- 8.9.0 — 2017-11-19
- 8.8.0 — 2017-09-24
- 8.7.0 — 2017-05-09
- 8.6.0 — 2017-03-24
- 8.5.0 — 2017-01-24
- 8.4.0 — 2016-12-01
- 8.3.0 — 2016-10-04
- … 57 more at https://npm.io/package/bell/versions

## README

# **bell**

Third-party authentication plugin for [hapi](https://github.com/hapijs/hapi).

Lead Maintainer: [Adri Van Houdt](https://github.com/adrivanhoudt)

[![Build Status](https://secure.travis-ci.org/hapijs/bell.png)](http://travis-ci.org/hapijs/bell)

**bell** ships with built-in support for authentication using `Facebook`, `GitHub`, `Google`,
`Google Plus`, `Instagram`, `LinkedIn`, `Slack`, `Stripe`, `Twitter`, `Yahoo`, `Foursquare`,
`VK`, `ArcGIS Online`, `Windows Live`, `Nest`, `Phabricator`, `BitBucket`, `Dropbox`, `Reddit`,
`Tumblr`, `Twitch`, `Mixer`, `Salesforce`, `Pinterest`, `Discord`, `DigitalOcean`, `AzureAD`,
`trakt.tv` and `Okta`.

It also supports any compliant `OAuth 1.0a` and `OAuth 2.0` based login services with a simple
configuration object.

## Documentation

[**API Documentation**](API.md)

[**Providers Documentation**](Providers.md)

## Tutorials

[**Social Login with Twitter using hapi.js**](http://mph-web.de/social-signup-with-twitter-using-hapi-js/)

## Examples

[**All Examples**](/examples)

Twitter:

```js
// Load modules

const Bell = require('bell');
const Hapi = require('hapi');


// Declare internals

const internals = {};


internals.start = async function () {

    const server = Hapi.server({ port: 8000 });

    // Register bell with the server

    await server.register(Bell);

    // Declare an authentication strategy using the bell scheme
    // with the name of the provider, cookie encryption password,
    // and the OAuth client credentials.

    server.auth.strategy('twitter', 'bell', {
        provider: 'twitter',
        password: 'cookie_encryption_password_secure',
        clientId: 'my_twitter_client_id',
        clientSecret: 'my_twitter_client_secret',
        isSecure: false     // Terrible idea but required if not using HTTPS especially if developing locally
    });

    // Use the 'twitter' authentication strategy to protect the
    // endpoint handling the incoming authentication credentials.
    // This endpoint usually looks up the third party account in
    // the database and sets some application state (cookie) with
    // the local application account information.

    server.route({
        method: ['GET', 'POST'],    // Must handle both GET and POST
        path: '/login',             // The callback endpoint registered with the provider
        options: {
            auth: 'twitter',
            handler: function (request, h) {

                if (!request.auth.isAuthenticated) {
                    return `Authentication failed due to: ${request.auth.error.message}`;
                }

                // Perform any account lookup or registration, setup local session,
                // and redirect to the application. The third-party credentials are
                // stored in request.auth.credentials. Any query parameters from
                // the initial request are passed back via request.auth.credentials.query.

                return h.redirect('/home');
            }
        }
    });

    await server.start();
};

internals.start();
```

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