oauthclient
Version:
module using oauth
48 lines (40 loc) • 2.25 kB
Markdown

> Client OAuth 1.0a Request Authorization for Node
[](http://gruntjs.com/)
[](https://semaphoreci.com/omher/oauthclient)
[](https://codeclimate.com/github/OmerHerera/oauthclient)
[](https://david-dm.org/OmerHerera/oauthclient)
[](https://david-dm.org/OmerHerera/oauthclient#info=devDependencies)
[](http://badge.fury.io/js/oauthclient)
[](https://img.shields.io/npm/dm/oauthclient.svg)
[](https://nodei.co/npm/oauthclient/)
### Example
### API
* ```create(options)``` - creates instance, create unique instance(supports Singletone)
* ```public``` - public key
* ```secret``` - secret key
* ```fetch(request object, callback)```
* ```request object``` - must have
1. URL - URL to request - ```mandatory```
2. Method - Method to use, GET/POST - ```mandatory```
3. body - data when using POST method - ```optonal```
4. json - ```true/false``` - ```optional```
* true when passing objet
* false when passing string
* ```callback``` - The callback argument gets 2 arguments:
1. An error when applicable (usually from http.ClientRequest object)
2. An http.IncomingMessage object
### Example
```
var oauthClient = require("oauthclient").create({
public: "asdfg2345tghj89uk9klas34d5f6g7uhj9kl",
secret: "s3d4f56g7h8jk09j8h7g6fcvb7n8m90"
};
var requestObj = {
"method": "GET",
"url": "https:///www.domain.taht.spports.oauth1.0"
};
oauthClientInstance.fetch(requestObj, function (err, data) {
/// do somthing with err or data
});
```