1.1.1 • Published 5 years ago

passport-weapp v1.1.1

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

passport-weapp

Passport for 微信小程序

npm download NPM version Build Status Dependencies Status Coverage Status code style: prettier Git commit with emojis! semantic-release

Passport strategy for authenticating with Wechat Mini Program

##支持功能

  • 微信小程序登录

安装

$ npm install passport-weapp

使用

Configure Strategy

 passport.use(new WeappStrategy({
        appID: {APPID},
        name:{默认为wechat,可以设置组件的名字}
        appSecret: {APPSECRET},
        getToken: {getToken},
        saveToken: {saveToken}
      },
      function(accessToken, refreshToken, profile,expires_in, done) {
        return done(err,profile);
      }
));

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

Authenticate Requests

router.get("/auth/weapp", passport.authenticate("weapp", 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.

License

Copyright (c) 2019 jeff-tian
Licensed under the MIT license.