koa-openid
koa openid plugin
Last updated 2 years ago by soonwang .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install koa-openid 
SYNC missed versions from official npm registry.

koa-openid

Installation

    npm i koa-openid -S

Example

const Koa = require('koa');
const router = require('koa-router')();
const Openid = require('koa-openid');

const app = new Koa();
const openidConfig = {
    client_id: '****',
    client_secret: '****',
    redirect_uri: 'http://hostname/login'
};
const openid = new Openid(openidConfig);

router.get('/', async function(ctx, next) {
    //判断用户未登录
    if(true) {
        return await openid.goLogin(ctx);
    }
});
router.get('/login', async function(ctx, next) {
    return await openid.getUserInfo(ctx, next, function(result) {
        if(!result.error) {
            console.log(result.userInfo);
        }
    })
})

API

CONFIG

{
    client_id: '****',  //必须
    client_secret: '****', //必须
    redirect_uri: 'http://hostname/login', //必须 登录成功后,Openid重定向地址
    scope: 'openid fullname nickname email', //具体查看文档https://login.netease.com/download/oidc_docs/flow/authorization_request.html
    base_uri: 'https://login.netease.com/connect', //OpenId Provider 的地址
    authorize_uri: 'https://login.netease.com/connect/authorize', //认证授权请求地址
    token_uri: 'https://login.netease.com/connect/token', //Token Endpoint 应用请求Token地址
    userinfo_uri: 'https://login.netease.com/connect/userinfo' //获取用户信息地址
}

Current Tags

  • 0.2.1                                ...           latest (2 years ago)

11 Versions

  • 0.2.1                                ...           2 years ago
  • 0.2.0                                ...           2 years ago
  • 0.1.8                                ...           2 years ago
  • 0.1.7                                ...           2 years ago
  • 0.1.6                                ...           2 years ago
  • 0.1.5                                ...           2 years ago
  • 0.1.4                                ...           2 years ago
  • 0.1.3                                ...           2 years ago
  • 0.1.2                                ...           2 years ago
  • 0.1.1                                ...           2 years ago
  • 0.1.0                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 2
This Month 2
Last Day 0
Last Week 0
Last Month 7
Dependencies (2)
Dev Dependencies (3)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |