Skip to content

sjsnider/simple-oauth2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple OAuth2

Node.js client library for Oauth2. Currently it supports Authorization Code and Resource Owner Password Credentials grant types.

Requirements

Node client library is tested against Node ~0.8.x

Installation

Install the client library using npm:

$ npm install simple-oath2

Install the client library using git:

$ git clone git://github.com/andrearegianto/simple-oauth2.git
$ cd simple-oauth2
$ npm install

Getting started

// Set the client credentials
var credentials = { client: {
  id: '<client-id>',
  secret: '<client-secret>',
  site: 'https://auth.service.com'
}};

// Initialize the OAuth2 Library
var OAuth2 = require('simple-oauth2')(credentials);

// Authorization OAuth2 URI
var authorization_uri = OAuth2.AuthCode.authorizeURL({
  redirect_uri: 'http://localhost:3000/callback'
});

// Redirect example using Express (see http://expressjs.com/api.html#res.redirect)
res.redirect(authorization_uri);

// Get the access token object (authorization code is given from previous step)
var token;
OAuth2.AuthCode.getToken({
  code: code,
  redirect_uri: 'http://localhost:3000/callback'
}, function(error, result) { token = result });

// Create the access token wrapper
var token = OAuth2.AccessToken.create(json_token);

Documentation

Check out the complete Simple OAuth2 website

Contributing

Fork the repo on github and send a pull requests with topic branches. Do not forget to provide specs to your contribution.

Running specs

  • Fork and clone the repository (dev branch).
  • Run npm install for dependencies.
  • Run make test to execute all specs.
  • Run make test-watch to auto execute all specs when a file change.

Coding guidelines

Follow github guidelines.

Feedback

Use the issue tracker for bugs. Mail or Tweet us for any idea that can improve the project.

Links

Authors

Andrea Reginato

Contributors

Special thanks to the following people for submitting patches.

Changelog

See CHANGELOG

Copyright

Copyright (c) 2013 Lelylan. See LICENSE for details.

About

A simple Node.js client library for Oauth2

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published