autwh

Twitter oAuth Helper

  • autwh

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
autwh
310.1.05 years ago6 years agoMinified + gzip package size for autwh in KB

Readme

autwh ------------------------------- !npm-badgenpm-link !mit-badgemit
A simple Twitter API authentication helper.
NPM

Install

``` shell $ npm install autwh ```

Usage

With Express

In this example, express-session is used, but other methods are also possible. ``` javascript import autwh from 'autwh'; import as express from 'express'; import as session from 'express-session'; const twAuth = autwh({
consumerKey: 'kyoppie',
consumerSecret: 'yuppie',
callbackUrl: 'https://my.app.example.com/twitter/callback'
}); const app = express(); app.use(session()); app.get('/twitter/connect', async (req, res) => {
const ctx = await twAuth.begin();
req.session.ctx = ctx;
res.redirect(ctx.url);
}); // URL used in 'callbackUrl' above app.get('/twitter/callback', async (req, res) => {
const ctx = await twAuth.done(req.session.ctx, req.query.oauth_verifier);
res.send(`Authorized! Hello ${ctx.screenName}.`);
}); ```

License

MIT