@creamery/oauth2client
A simple oauth2 client
Last updated 3 years ago by creamidea .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @creamery/oauth2client 
SYNC missed versions from official npm registry.

Oauth2Client

A simple oauth2 client

Usage

const Oauth2Client = require('@creamery/oauth2client')

const oauth2Client = new Oauth2Client({
  baseUrl,
  oauthPath,
  tokenPath,
  redirectURI,
  appId,
  appSecret
})

// and then you can use it like the code below
app.use(async (ctx, next) => {
  ...
  // here assume that is the code
  if (ctx.query.code) {
    const body = oauth2Client.requestToken(code)
    ctx.session.accessToken = body.access_token
    // if calling requestToken is failed,
    // it will throw the ERROR. You can catch it.
  }
  ...

  if (!ctx.session.accessToken) {
    oauth2Client.redirectToAuthorizedURI(ctx)
    ...
  }
  ...
})

Current Tags

  • 1.0.1                                ...           latest (3 years ago)

2 Versions

  • 1.0.1                                ...           3 years ago
  • 1.0.0                                ...           3 years ago
Maintainers (1)
Downloads
Today 0
This Week 1
This Month 3
Last Day 0
Last Week 2
Last Month 1
Dependencies (1)
Dev Dependencies (7)
Dependents (1)

Copyright 2014 - 2016 © taobao.org |