Coder Social home page Coder Social logo

bitlogin's Introduction

公众号换取 openID

参考文档

https://pm2.keymetrics.io/docs/usage/pm2-doc-single-page/

https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/Wechat_webpage_authorization.html

部署

需要 node 10 以上

docker 可使用 node:12-alpine 镜像

# 安装依赖
npm i
# 如果需要开发则要安装typescript 部署不用
# tsc
# 部署
npx pm2 start ./dist/app.js --name bitlogin
#查看状态
npx pm2 ls
# 重启
npx pm2 restart bitlogin
# 查看日志
npx pm2 log bitlogin

api 使用

登陆

获取 code

默认跳转下一个接口,不需要跳转的redirectOther=1

**xxxx.yy **这个域名必须在公众号上配置公众号设置=>网页授权域名

http://xxxx.yy/?state=key&redirectOther=0

参数 说明 必须
state 业务对应的 key,这个每个业务都需要在后台进行配置
redirectOther 是否跳转到 key 对应的地址,默认跳回本服务自动换取 openid

code2openid

通过 code 获取 openid

默认由上面接口自动跳转到微信再跳回这个接口

http://xxxx.yy/code2openid?code=iiiiii&state=key

参数 说明 必须
code 微信登陆后获得的 code
state 业务对应的 key,这个每个业务都需要在后台进行配置

.env 文件

根目录下须有该文件

下面是模板

# 业务配置 key=链接
# 变更后务必重启服务
test1=http://wuxinke.top:13000
ww4=https://wishingwall.bitworkshop.cn

# 端口
PORT=13000
# appid & secret
APPID=xxxxxx
SECRET=xxxxx

bitlogin's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.