Update Readme.md
added test/example to get bearer/access_token from Twitter using consumer key+secret and OAuth2
This commit is contained in:
parent
37bf1081ea
commit
c161653add
28
Readme.md
28
Readme.md
@ -13,6 +13,34 @@ Installation
|
|||||||
$ npm install oauth
|
$ npm install oauth
|
||||||
|
|
||||||
|
|
||||||
|
Examples
|
||||||
|
==========
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
describe('Trends',function(){
|
||||||
|
var request = require('superagent');
|
||||||
|
var OAuth = require('OAuth').OAuth;
|
||||||
|
|
||||||
|
it('gets bearer token', function(done){
|
||||||
|
var OAuth2 = require('OAuth').OAuth2;
|
||||||
|
var twitterConsumerKey = 'your key';
|
||||||
|
var twitterConsumerSecret = 'your secret';
|
||||||
|
var oauth2 = new OAuth2(server.config.keys.twitter.consumerKey,
|
||||||
|
twitterConsumerSecret,
|
||||||
|
'https://api.twitter.com/',
|
||||||
|
null,
|
||||||
|
'oauth2/token',
|
||||||
|
null);
|
||||||
|
oauth2.getOAuthAccessToken(
|
||||||
|
'',
|
||||||
|
{'grant_type':'client_credentials'},
|
||||||
|
function (e, access_token, refresh_token, results){
|
||||||
|
console.log('bearer: ',access_token);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
Change History
|
Change History
|
||||||
==============
|
==============
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user