Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
sample
README.md
index.js
package.json

README.md

node-oauth

An adaptor for OAuth 1.0 and OAuth 2.0 API.

Install

npm install node-oauth

Usage

require node-oauth

var OAuth = require('node-oauth');

set your application OAuth setting file.

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);
    }
  });

(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 oauthAuthorizer = OAuth.authorize('twitter', {
    auto: false
  });

get access token in redirect page Tokener object returns.

var oauthTokener = OAuth.access(oauth['type'], {
        href: location.href
      }, authorized);

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).

oauthTokener.get("credentials", {}, function(err, data){
  if(err)
    return ...
  ...
  });
Something went wrong with that request. Please try again.