koa-github - simple github auth middleware for koa

  •        0

```//use http://localhost:7001 to testvar koa = require('koa');var http = require('http');var session = require('koa-sess');var githubAuth = require('koa-github');var app = koa();app.name = 'nae-web';app.keys = ['key1', 'key2'];app.use(session());app.use(githubAuth({ clientID: '5ec1d25d2a3baf99a03c', clientSecret: '513607494a244e2759738cae3d50a89494c1e7f0', callbackURL: 'http://localhost:7001', userKey: 'user', timeout: 10000}));app.use(function *handler() { if (!this.session.githubToken) { this.body = 'login with github'; } else { this.body = this.session.user; }});app.on('error', function (err) { if (!err.status || err.status >= 500) { logger.error(err); }});http.createServer(app.callback()).listen(7001);```




comments powered by Disqus

Related Projects

koa-redis - koa session with redis

`koa-redis` works with [koa-generic-session](https://github.com/koajs/generic-session)(a generic session middleware for koa).

koa-markdown - Auto convert markdown to html for koa. Inspired by connect-markdown

```jsvar koa = require('koa');var markdown = require('koa-markdown');var app = koa();app.use(markdown({ root: __dirname + '/docs', baseUrl: '/docs'}));app.listen(7001);```Or you can checkout the [example](https://github.com/koajs/koa-markdown/tree/master/example).

body-parsers - collection of koa body parsers

Includes a `json`, `urlencoded`, and `multipart` parsers,as well as a utility to save streams to disk.See https://github.com/koajs/koala/blob/master/docs/body-parsing.md for more details.

path-match - koa route middleware

[![NPM version][npm-image]][npm-url][![build status][travis-image]][travis-url][![Test coverage][coveralls-image]][coveralls-url][![Gittip][gittip-image]][gittip-url]A simple routing wrapper around [path-match](https://github.com/expressjs/path-match).Similar to [koa-route](https://github.com/koajs/route) except it doesn't check methods.All of these routers use [path-to-regexp](https://github.com/component/path-to-regexp)underneath, which is what Express uses as well.```jsvar route = require('ko

Open source products are scattered around the web. Please provide information about the open source projects you own / you use. Add Projects.

Tag Cloud >>