Skip to content

LiuLianJie/koa2-weixin-oauth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

使用用例
	const Koa = require("koa");
	const Router = require("koa-router");
	const Auth = require("koa2-weixin-auth");

	const app = new Koa();
	const router = new Router();
	const auth = new Auth("appid","appsecret");

	router.get("/", async(ctx, next) => {
		const url = await auth.getAuthorizeURL('redirect_url','snsapi_userinfo','');
		ctx.redirect(url);
	})

	router.get("/getcode", async(ctx, next) => {
		const token = await auth.getAccessToken(ctx.request.query.code);
		const accessToken = token.data.access_token;
		const openid = token.data.openid;
		const userinfo = await auth.getUser(openid);
		
	})

	app.use(router.routes());
	app.listen(3000);

About

为koa2 做的 微信公众平台授权模块

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published