# passport-ground-truth

> Passport authentication strategy for Ground Truth

Latest version **1.0.3** (published 2021-09-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install passport-ground-truth
pnpm add passport-ground-truth
yarn add passport-ground-truth
bun add passport-ground-truth
```

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2021-09-13 |
| First published | 2021-07-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 8.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Ayush Goyal |
| Maintainers | agoyal1 |
| Keywords | passport, auth, authentication, node, hackgt |

## Links

- npm: https://www.npmjs.com/package/passport-ground-truth
- Repository: https://github.com/HackGT/passport-ground-truth
- Homepage: https://github.com/HackGT/passport-ground-truth#readme
- Issues: https://github.com/HackGT/passport-ground-truth/issues
- npm.io page: https://npm.io/package/passport-ground-truth

## Dependencies (1)

- [passport-oauth2](https://npm.io/package/passport-oauth2.md) ^1.6.0

## 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.3 (latest) — 2021-09-13
- 1.0.2 — 2021-09-13
- 1.0.1 — 2021-07-29
- 1.0.0 — 2021-07-29
- 0.0.5 — 2021-07-29
- 0.0.4 — 2021-07-29
- 0.0.3 — 2021-07-29
- 0.0.2 — 2021-07-28
- 0.0.1 — 2021-07-28

## README

# passport-ground-truth

[Passport](https://github.com/jaredhanson/passport) strategy for authenticating with HexLab's [Ground Truth](https://github.com/hackgt/ground-truth) using the OAuth 2.0 API.

This module lets you authenticate using Ground Truth in your Node.js applications. You can easily use Passport to integrate into different frameworks like express.

## Install

```shell
$ npm install passport-ground-truth --save
```

## Usage

### Configure Strategy

The Ground Truth authentication strategy authenticates users using a Ground Truth 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, base URL, and callback URL.

```js
import { Strategy as GroundTruthStrategy } from "passport-ground-truth";

passport.use(
  new GroundTruthStrategy(
    {
      clientID: process.env.GROUND_TRUTH_CLIENT_ID,
      clientSecret: process.env.GROUND_TRUTH_CLIENT_SECRET,
      baseURL: process.env.GROUND_TRUTH_URL,
      callbackURL: "/auth/login/callback",
    },
    async (req, accessToken, refreshToken, profile, done) {
      User.findOrCreate({ id: profile.id }, function (err, user) {
        return done(err, user);
      });
    }
  )
);
```

### Authenticate Requests

Use `passport.authenticate()`, specifying the `"groundtruth"` strategy, to
authenticate requests.

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

```js
import express from "express";

export let authRoutes = express.Router();

authRoutes.get("/login", passport.authenticate("groundtruth"));

authRoutes.get(
  "/login/callback",
  passport.authenticate("groundtruth", {
    failureRedirect: "/",
    successReturnToOrRedirect: "/",
  }),
  (req, res) => {
    // Successful authentication, redirect home.
    res.redirect("/");
  }
);
```

## Attribution

- [passport-instagram](https://github.com/jaredhanson/passport-instagram)

## License

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

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