# passport-wechat

> passport strategy for authenticating with wechat

Latest version **2.0.4** (published 2016-10-05) · MIT license · 0 weekly downloads

## Install

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

## 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 | 2.0.4 |
| Published | 2016-10-05 |
| First published | 2014-07-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 156 |
| Author | liangyali |
| Maintainers | liangyali |
| Keywords | passport, wechat, weixin |

## Links

- npm: https://www.npmjs.com/package/passport-wechat
- Repository: https://github.com/liangyali/passport-wechat
- Homepage: http://www.liangyali.com
- Issues: https://github.com/liangyali/passport-wechat/issues
- npm.io page: https://npm.io/package/passport-wechat

## Dependencies (5)

- [debug](https://npm.io/package/debug.md) latest
- [xtend](https://npm.io/package/xtend.md) ^4.0.0
- [passport](https://npm.io/package/passport.md) ^0.3.0
- [wechat-oauth](https://npm.io/package/wechat-oauth.md) ^1.0.1
- [passport-strategy](https://npm.io/package/passport-strategy.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
- [@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

- 2.0.4 (latest) — 2016-10-05
- 2.0.3 — 2016-09-17
- 2.0.2 — 2015-12-09
- 2.0.1 — 2015-12-09
- 2.0.0 — 2015-09-16
- 0.1.3 — 2015-03-17
- 0.1.2 — 2014-11-19
- 0.1.1 — 2014-11-19
- 0.1.0 — 2014-11-19
- 0.0.9 — 2014-11-11
- 0.0.8 — 2014-08-11
- 0.0.7 — 2014-08-08
- 0.0.6 — 2014-08-08
- 0.0.5 — 2014-08-08
- 0.0.4 — 2014-08-08
- … 4 more at https://npm.io/package/passport-wechat/versions

## README

# passport-wechat v2.0

[![Dependencies](https://david-dm.org/liangyali/passport-wechat.svg)](https://david-dm.org/liangyali/passport-wechat)

[Passport](http://passportjs.org/) strategy for authenticating with [Wechat](http://weixin.qq.com/)

##支持功能

* 微信公众账号
* 微信网站登陆

## 安装

    $ npm install passport-wechat
    
## 使用
#### Configure  Strategy

```js

 passport.use(new WechatStrategy({
        appID: {APPID},
        name:{默认为wechat,可以设置组件的名字}
        appSecret: {APPSECRET},
        client:{wechat|web},
        callbackURL: {CALLBACKURL},
        scope: {snsapi_userinfo|snsapi_base},
        state:{STATE},
        getToken: {getToken},
        saveToken: {saveToken}
      },
      function(accessToken, refreshToken, profile, done) {
        return done(err,profile);
      }
));

The `callbackURL`, `scope` and `state` can be overwritten in `passport.authenticate` middleware.

The `getToken` and `saveToken` can be provided to initialize Wechat OAuth instance.

```

#### Authenticate Requests

```js
  router.get('/auth/wechat', passport.authenticate('wechat', options));
```
`options` - Optional. Can include the following:
* `state` - Override state for this specific API call
* `callbackURL` - Override callbackURL for this specific API call
* `scope` - Override scope for this specific API call

If no callbackURL is specified, the same request url will be used.

#### Authentication Callback

```js
  router.get('/auth/wechat/callback', passport.authenticate('wechat', {
    failureRedirect: '/auth/fail',
    successReturnToOrRedirect: '/'
  }));
```

## License

Copyright (c) 2014 liangyali  
Licensed under the MIT license.

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