forked from rainux/node-oauth
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
50 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,84 +1,70 @@ | ||
node-oauth | ||
:: node-oauth :: | ||
= | ||
|
||
An adaptor for OAuth 1.0 and OAuth 2.0 API. | ||
##Abstract | ||
#### An adaptor for OAuth 1.0 and OAuth 2.0 API. | ||
|
||
Install | ||
- | ||
##Install## | ||
|
||
npm install node-oauth | ||
To install the most recent release from npm, run: | ||
|
||
npm install node-oauth | ||
|
||
Usage | ||
- | ||
##Usage## | ||
|
||
require `node-oauth` | ||
> require `node-oauth` | ||
```js | ||
var OAuth = require('node-oauth'); | ||
var OAuth = require('node-oauth'); | ||
|
||
``` | ||
> set your application OAuth setting file. | ||
set your application OAuth setting file. | ||
OAuth = OAuth("../sample/object-oauth.js") | ||
|
||
```js | ||
OAuth = OAuth("../sample/object-oauth.js") | ||
> jump to Login page. | ||
> "response" is necessary for redirect. | ||
``` | ||
OAuth.authorize('facebook',{ | ||
response: res, | ||
endCallback: function(err) { | ||
if(err) | ||
onError(err); | ||
} | ||
}); | ||
|
||
jump to Login page. | ||
"response" is necessary for redirect. | ||
> (OAuth 1.0) | ||
> if you don't want to go authorize page everytime, you can control after getting request token. | ||
> Authorizer object returns. It have setting datas on its fields. | ||
```js | ||
OAuth.authorize('facebook',{ | ||
response: res, | ||
endCallback: function(err) { | ||
if(err) | ||
onError(err); | ||
} | ||
}); | ||
var oauthAuthorizer = OAuth.authorize('twitter', { | ||
auto: false | ||
}); | ||
|
||
``` | ||
> get access token in redirect page | ||
> Tokener object returns. | ||
(OAuth 1.0) | ||
if you don't want to go authorize page everytime, you can control after getting request token. | ||
Authorizer object returns. It have setting datas on its fields. | ||
var oauthTokener = OAuth.access(oauth['type'], { | ||
href: location.href | ||
}, authorized); | ||
|
||
```js | ||
var oauthAuthorizer = OAuth.authorize('twitter', { | ||
auto: false | ||
}); | ||
> if you want to set access_token externaly, ( that is , not via url ) | ||
``` | ||
oauthTokener.set({ | ||
request_token: oauth['req_tkn'], | ||
access_token: oauth['oac_tkn'], | ||
access_token_secret: oauth['oac_tkn_scr'] | ||
}); | ||
|
||
get access token in redirect page | ||
Tokener object returns. | ||
> access to api with name (set in setting file) / url. | ||
> data returns after JSON.parse(api-response). | ||
```js | ||
var oauthTokener = OAuth.access(oauth['type'], { | ||
href: location.href | ||
}, authorized); | ||
oauthTokener.get("credentials", {}, function(err, data){ | ||
if(err) | ||
return ... | ||
... | ||
}); | ||
|
||
``` | ||
##Change Log## | ||
|
||
if you want to set access_token externaly, ( that is , not via url ) | ||
|
||
```` | ||
oauthTokener.set({ | ||
request_token: oauth['req_tkn'], | ||
access_token: oauth['oac_tkn'], | ||
access_token_secret: oauth['oac_tkn_scr'] | ||
}); | ||
```` | ||
|
||
access to api with name (set in setting file) / url. data returns after JSON.parse(api-response). | ||
|
||
```js | ||
oauthTokener.get("credentials", {}, function(err, data){ | ||
if(err) | ||
return ... | ||
... | ||
}); | ||
|
||
``` | ||
* 2013/4/16 | ||
+ 0.1.2 release | ||
+ repository owner is changed to ystskm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters