Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/syuilo/autwh
Simple Twitter OAuth module for Node.js
https://github.com/syuilo/autwh
nodejs oauth twitter twitter-api
Last synced: 25 days ago
JSON representation
Simple Twitter OAuth module for Node.js
- Host: GitHub
- URL: https://github.com/syuilo/autwh
- Owner: syuilo
- License: mit
- Created: 2017-01-20T23:18:46.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-04-09T08:28:17.000Z (over 6 years ago)
- Last Synced: 2024-09-16T03:45:26.788Z (about 2 months ago)
- Topics: nodejs, oauth, twitter, twitter-api
- Language: TypeScript
- Size: 4.88 KB
- Stars: 3
- Watchers: 4
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
autwh
-------------------------------[![][npm-badge]][npm-link]
[![][mit-badge]][mit]> A simple Twitter API authentication helper.
[![NPM](https://nodei.co/npm/autwh.png?downloads=true&downloadRank=true&stars=true)](https://www.npmjs.com/package/autwh)
## Install
``` shell
$ npm install autwh
```## Usage
### With [Express](https://github.com/expressjs/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](LICENSE)[npm-link]: https://www.npmjs.com/package/autwh
[npm-badge]: https://img.shields.io/npm/v/autwh.svg?style=flat-square
[mit]: http://opensource.org/licenses/MIT
[mit-badge]: https://img.shields.io/badge/license-MIT-444444.svg?style=flat-square