passport-wechat-api

0.0.1 • Public • Published

passport-wechat-api

集成微信小程序,微信开放平台授权登录api

Installation

$ npm install passport-wechat-api --save 

Usage

注册Strategy

passport.use(new WechatStrategy({
        name: 'name', //枚举【wechat,miniProgram】,如未设置,isMiniProgram为true时默认为miniProgram,反之为wechat
        appID: 'appID',
        appSecret: 'appSecret',
        isMiniProgram: true, //是否小程序授权登录,默认false
        getToken: Function getToken,
        saveToken: Function saveToken
      },
      function([req可选],accessToken, refreshToken, profile, result, done) {
        return done(err,profile);
      }
));

匹配路由

router.get('/auth/wechat', passport.authenticate('wechat', options));
get /auth/wechat?code=xxx

Licence

The MIT License (MIT)

Copyright (c) 2019 追疯

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Package Sidebar

Install

npm i passport-wechat-api

Weekly Downloads

0

Version

0.0.1

License

MIT

Unpacked Size

6.79 kB

Total Files

4

Last publish

Collaborators

  • kenchar