1 | # Simple OAuth2
|
2 |
|
3 | Node.js client library for [Oauth2](http://oauth.net/2/).
|
4 | Currently it supports Authorization Code and Resource Owner Password Credentials grant types.
|
5 |
|
6 |
|
7 | ## Requirements
|
8 |
|
9 | Node client library is tested against Node ~0.8.x
|
10 |
|
11 |
|
12 | ## Installation
|
13 |
|
14 | Install the client library using [npm](http://npmjs.org/):
|
15 |
|
16 | $ npm install simple-oath2
|
17 |
|
18 | Install the client library using git:
|
19 |
|
20 | $ git clone git://github.com/andrearegianto/simple-oauth2.git
|
21 | $ cd simple-oauth2
|
22 | $ npm install
|
23 |
|
24 |
|
25 | ## Getting started
|
26 |
|
27 | ```javascript
|
28 | var credentials = { client: { id: 'client-id', secret: 'client-secret', site: 'https://example.org' } };
|
29 | var OAuth2 = require('simple-oauth2')(credentials);
|
30 |
|
31 | // Returns the URI where to redirect your app
|
32 | var redirect = Oauth2.AuthCode.authorizeURL({ redirectURI: 'http://localhost:3000/callback', scope: 'user', state: '02afe928b');
|
33 | // => "https://example.org/oauth/authorization?response_type=code&client_id=client_id&redirect_uri=http://localhost:3000/callback&scope=user&state=02afe928b"
|
34 |
|
35 | // Get the access token object
|
36 | vat params = { code: 'authorization-code', redirectURI: 'http://localhost:3000/callback' }
|
37 | OAuth2.AuthCode.getToken(params, function(error, result) {
|
38 | // save the token
|
39 | })
|
40 | ```
|
41 |
|
42 | ## Documentation
|
43 |
|
44 | Check out the complete [Simple Oauth2 Documentation](http://andreareginato.github.com/simple-oauth2)
|
45 |
|
46 |
|
47 | ## Contributing
|
48 |
|
49 | Fork the repo on github and send a pull requests with topic branches. Do not forget to
|
50 | provide specs to your contribution.
|
51 |
|
52 |
|
53 | ### Running specs
|
54 |
|
55 | * Fork and clone the repository (`dev` branch).
|
56 | * Run `npm install` for dependencies.
|
57 | * Run `make test` to execute all specs.
|
58 | * Run `make test-watch` to auto execute all specs when a file change.
|
59 |
|
60 |
|
61 | ## Coding guidelines
|
62 |
|
63 | Follow [github](https://github.com/styleguide/) guidelines.
|
64 |
|
65 |
|
66 | ## Feedback
|
67 |
|
68 | Use the [issue tracker](http://github.com/andreareginato/simple-oauth2/issues) for bugs.
|
69 | [Mail](mailto:andrea.reginato@.gmail.com) or [Tweet](http://twitter.com/andreareginato) us
|
70 | for any idea that can improve the project.
|
71 |
|
72 |
|
73 | ## Links
|
74 |
|
75 | * [GIT Repository](http://github.com/andreareginato/simple-oauth2)
|
76 | * [Documentation](http://andreareginato.github.com/simple-oauth2)
|
77 |
|
78 |
|
79 | ## Authors
|
80 |
|
81 | [Andrea Reginato](http://twitter.com/andreareginato)
|
82 |
|
83 |
|
84 | ## Contributors
|
85 |
|
86 | Special thanks to the following people for submitting patches.
|
87 |
|
88 |
|
89 | ## Changelog
|
90 |
|
91 | See [CHANGELOG](simple-oauth2/blob/master/CHANGELOG.md)
|
92 |
|
93 |
|
94 | ## Copyright
|
95 |
|
96 | Copyright (c) 2013 [Lelylan](http://lelylan.com). See [LICENSE](simple-oauth2/blob/master/LICENSE.md) for details.
|