UNPKG

2.53 kBMarkdownView Raw
1# Simple OAuth2
2
3Node.js client library for [Oauth2](http://oauth.net/2/).
4Currently it supports Authorization Code and Resource Owner Password Credentials grant types.
5
6
7## Requirements
8
9Node client library is tested against Node ~0.8.x
10
11
12## Installation
13
14Install the client library using [npm](http://npmjs.org/):
15
16 $ npm install simple-oath2
17
18Install 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
28var credentials = { client: { id: 'client-id', secret: 'client-secret', site: 'https://example.org' } };
29var OAuth2 = require('simple-oauth2')(credentials);
30
31// Returns the URI where to redirect your app
32var 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
36vat params = { code: 'authorization-code', redirectURI: 'http://localhost:3000/callback' }
37OAuth2.AuthCode.getToken(params, function(error, result) {
38 // save the token
39})
40```
41
42## Documentation
43
44Check out the complete [Simple Oauth2 Documentation](http://andreareginato.github.com/simple-oauth2)
45
46
47## Contributing
48
49Fork the repo on github and send a pull requests with topic branches. Do not forget to
50provide 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
63Follow [github](https://github.com/styleguide/) guidelines.
64
65
66## Feedback
67
68Use 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
70for 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
86Special thanks to the following people for submitting patches.
87
88
89## Changelog
90
91See [CHANGELOG](simple-oauth2/blob/master/CHANGELOG.md)
92
93
94## Copyright
95
96Copyright (c) 2013 [Lelylan](http://lelylan.com). See [LICENSE](simple-oauth2/blob/master/LICENSE.md) for details.