Nearly Perpendicular Macaroons

    twitter-tokens

    1.0.3 • Public • Published

    twitter-tokens

    NPM version Dependency Status

    get twitter tokens

    Use with twitter or twit package. Twitter tokens is basically an object of twitter tokens exported from environment. At some point of twitter api usage I become tired to copy-pasted tokens.js file in a lot of my projects, so I decided to extract this file to separate npm package.

    You need to get Twitter API tokens first to be able to use this package.

    Install

    npm install --save twitter-tokens
    

    Usage

    import Twitter from 'twitter'; // or 'twit'. it works with both of them
     
    /* Before:
    const tokens = {
      consumer_key:        process.env.TWITTER_CONSUMER_KEY,
      consumer_secret:     process.env.TWITTER_CONSUMER_SECRET,
      access_token:        process.env.TWITTER_ACCESS_TOKEN_KEY,
      access_token_key:    process.env.TWITTER_ACCESS_TOKEN_KEY,
      access_token_secret: process.env.TWITTER_ACCESS_TOKEN_SECRET
    }); */
     
    // Now:
    import tokens from 'twitter-tokens';
     
    const client = new Twitter(tokens);
    const params = { screen_name: 'nodejs' };
    client.get('statuses/user_timeline', params, (err, tweets) => {
      if (err) throw err;
      console.log(tweets);
    });

    Related

    License

    MIT © Vladimir Starkov

    Install

    npm i twitter-tokens

    DownloadsWeekly Downloads

    35

    Version

    1.0.3

    License

    MIT

    Last publish

    Collaborators

    • iamstarkov