# unsplash-passport

> Passport Strategy for Sign with Unsplash

Latest version **1.0.3** (published 2020-08-27) · MIT license · 0 weekly downloads

## Install

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

## 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.3 |
| Published | 2020-08-27 |
| First published | 2020-08-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 19.4 KB |
| Known vulnerabilities | 0 (+4 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Neeraj Pandey |
| Maintainers | neerajp99 |
| Keywords | unsplash, passport, authentcation, oauth, passportjs, strategy, authentication, identity |

## Links

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

## Dependencies (5)

- [express](https://npm.io/package/express.md) ^4.17.1
- [passport](https://npm.io/package/passport.md) ^0.4.1
- [body-parser](https://npm.io/package/body-parser.md) ^1.19.0
- [jsonwebtoken](https://npm.io/package/jsonwebtoken.md) ^8.5.1
- [passport-oauth2](https://npm.io/package/passport-oauth2.md) ^1.5.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
- [@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

## Recent versions

- 1.0.3 (latest) — 2020-08-27
- 1.0.2 — 2020-08-27
- 1.0.1 — 2020-08-27
- 1.0.0 — 2020-08-27

## README

#  Sign in with Unsplash for Passport JS

<a href="https://twitter.com/intent/follow?screen_name=neerajp99"><img src="https://img.shields.io/twitter/follow/neerajp99.svg?label=Follow%20@neerajp99" alt="Follow @neerajp99"></img></a>
<a href="https://www.npmjs.com/package/unsplash-passport">
  <img src="https://img.shields.io/npm/v/unsplash-passport.svg"></img>
</a>
</p>

Passport Strategy for the sign in with Unsplash, with profile information ✅!


## Installation
Install the package via npm / yarn:
``` npm install --save unsplash-passport ```

You will also need to install & configure `body-parser` if using Express:
``` npm install --save body-parser ```

```js
const bodyParser = require("body-parser");
app.use(bodyParser.urlencoded({ extended: true }));
```

Next, you need to configure your Unsplash Developer account by creating OAuth applications here: [https://unsplash.com/developers](https://unsplash.com/developers)



## Usage

The Unsplash authentication strategy authenticates users via Unsplash user account and OAuth 2.0 token(s). An  Unsplash API Client ID, secret and redirect URL must be supplied when using this strategy. The strategy also requires a `verify` callback, which receives the access token and an optional refresh token, as well as a `profile` which contains the authenticated Unsplash user's profile. The `verify` callback must also call `cb` or `done` providing a user to complete the authentication.

Initialize the strategy as follows:

```js
const UnsplasgStrategy = require('unsplash-passport').Strategy;
let scopes = ['public', 'read_user'];
passport.use(new UnsplashStrategy({
    clientID: "",
    clientSecret: "",
    callbackURL: "",
    scope: scopes
}, function(accessToken, refreshToken, profile, done) {
    // asynchronous verification, for effect...
    process.nextTick(function () {
    return done(null, profile);
}));
```


#### Authenticate Requests

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

On successful authentication, add the callback route and handle the response.

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

```js
app.get('/auth/unsplash', passport.authenticate('unsplash'));

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

Developers using the popular [Express](http://expressjs.com/) web framework can refer to an [example](https://github.com/neerajp99/unsplash-auth-example) as a starting point for their own web applications. 

## Questions / Contributing

Feel free to open issues and pull requests. If you would like to be one of the core creators of this library, message me on twitter @neerajp99!

<h4> Created with ❤️ by <a href="https://http://github.com/neerajp99">Neeraj Pandey</a></h4>

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