Nice Pithy Motto

    autwh
    TypeScript icon, indicating that this package has built-in type declarations

    0.1.0 • Public • Published

    autwh

    A simple Twitter API authentication helper.

    NPM

    Install

    $ npm install autwh

    Usage

    With Express

    In this example, express-session is used, but other methods are also possible.

    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

    Keywords

    Install

    npm i autwh

    DownloadsWeekly Downloads

    1,923

    Version

    0.1.0

    License

    MIT

    Unpacked Size

    6.13 kB

    Total Files

    7

    Last publish

    Collaborators

    • syuilo