forked from lelylan/simple-oauth2
-
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.
Merge pull request lelylan#9 from fdeandao/dev
Dev
- Loading branch information
Showing
13 changed files
with
187 additions
and
40 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 |
---|---|---|
|
@@ -20,3 +20,6 @@ node_modules | |
|
||
# Docs | ||
docs/ | ||
|
||
.idea/ | ||
*.iml |
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 +1,3 @@ | ||
Copyright (c) 2013 Lelylan | ||
Copyright (c) 2013 lelylan, [lelylan.com](http://lelylan.com) | ||
|
||
This project is released under the [MIT License](http://opensource.org/licenses/MIT). |
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
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
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// | ||
// ### Client credentials flow implementation | ||
// | ||
module.exports = function(config) { | ||
|
||
var core = require('./../core')(config); | ||
|
||
// | ||
// ### Returns the Access Token object. | ||
// | ||
// * `params.scope` - A String that represents the application privileges. | ||
// * `callback` - The callback function returning the results. | ||
// An error object is passed as first argument and the result as last. | ||
// | ||
function getToken(params, callback) { | ||
params.grant_type = 'client_credentials'; | ||
core.api('POST', config.tokenPath, params, callback); | ||
} | ||
|
||
|
||
return { | ||
'getToken' : getToken | ||
} | ||
}; |
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,7 +1,9 @@ | ||
module.exports = { | ||
'authorizationPath' : '/oauth/authorize', | ||
'tokenPath' : '/oauth/token', | ||
'clientID': null, | ||
'clientID': null, | ||
'clientSecret': null, | ||
'site': null | ||
'site': null, | ||
'useBasicAuthorizationHeader': true, | ||
'clientSecretParameterName': 'client_secret' | ||
} |
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
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
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,6 +1,6 @@ | ||
{ | ||
"name": "simple-oauth2", | ||
"version": "0.1.7", | ||
"version": "0.1.8", | ||
"description": "Node.js client for OAuth2", | ||
"author": "Andrea Reginato <[email protected]>", | ||
"homepage": "http://github.com/andreareginato/simple-oauth2", | ||
|
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
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
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
var credentials = { clientID: 'client-id', clientSecret: 'client-secret', site: 'https://example.org', form: false }, | ||
OAuth2 = require('./../lib/simple-oauth2.js')(credentials), | ||
qs = require('querystring'), | ||
nock = require('nock'); | ||
|
||
var request, result, error; | ||
|
||
describe('OAuth2.Client',function() { | ||
|
||
describe('#getToken',function() { | ||
|
||
beforeEach(function(done) { | ||
var params = { 'grant_type': 'client_credentials', client_id: 'client-id', client_secret: 'client-secret' }; | ||
request = nock('https://example.org:443').post('/oauth/token', qs.stringify(params)).replyWithFile(200, __dirname + '/fixtures/access_token.json'); | ||
done(); | ||
}) | ||
|
||
beforeEach(function(done) { | ||
var params = {}; | ||
OAuth2.Client.getToken(params, function(e, r) { | ||
error = e; result = r; done(); | ||
}) | ||
}) | ||
|
||
it('makes the HTTP request', function() { | ||
request.isDone(); | ||
}); | ||
|
||
it('returns an access token',function() { | ||
result.should.have.property('access_token'); | ||
}); | ||
}); | ||
}); |
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