An open API service indexing awesome lists of open source software.

https://github.com/kaelzhang/weixin-auth

Wechat authorization
https://github.com/kaelzhang/weixin-auth

authorization nodejs wechat

Last synced: about 1 month ago
JSON representation

Wechat authorization

Awesome Lists containing this project

README

          

[![Build Status](https://travis-ci.org/kaelzhang/weixin-auth.svg?branch=master)](https://travis-ci.org/kaelzhang/weixin-auth)
[![Coverage](https://codecov.io/gh/kaelzhang/weixin-auth/branch/master/graph/badge.svg)](https://codecov.io/gh/kaelzhang/weixin-auth)

# weixin-auth

Wechat Authorization

## Install

```sh
$ npm install weixin-auth
```

## Usage

```js
import {WechatMP, mock} from 'weixin-auth'

const mp = new WechatMP({
appId: '',
secret: ''
})

await mp.auth(code)
// {
// openid: ...,
// unionid: ...,
// session_key: ...
// }

// We can mock the result for debugging purpose
mock({
openid: 'a',
unionid: 'b',
session_key: 'c'
})

await mp.auth(code)
// {
// openid: 'a',
// unionid: 'b',
// session_key: 'c'
// }
```

## License

MIT