Skip to content

Commit

Permalink
Merge pull request #71 from tinogomes/pullrequest
Browse files Browse the repository at this point in the history
Add `client_id` and `client_secret` on revoke_token
  • Loading branch information
ruipenso committed Feb 9, 2016
2 parents b2a8974 + 523060e commit 5518ed1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
11 changes: 9 additions & 2 deletions src/providers/oauth-provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,16 @@ function OAuthProvider() {
*/

revokeToken() {
var data = queryString.stringify({
var data = {
client_id: config.clientId,
token: OAuthToken.getRefreshToken() ? OAuthToken.getRefreshToken() : OAuthToken.getAccessToken()
});
};

if (null !== config.clientSecret) {
data.client_secret = config.clientSecret;
}

data = queryString.stringify(data);

var options = {
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
Expand Down
14 changes: 11 additions & 3 deletions test/unit/providers/oauth-provider.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,8 @@ describe('OAuthProvider', function() {
queryString.stringify.callCount.should.equal(1);
queryString.stringify.firstCall.args.should.have.lengthOf(1);
queryString.stringify.firstCall.args[0].should.eql({
client_id: defaults.clientId,
client_secret: defaults.clientSecret,
token: 'bar'
});
queryString.stringify.restore();
Expand All @@ -378,14 +380,18 @@ describe('OAuthProvider', function() {
queryString.stringify.callCount.should.equal(1);
queryString.stringify.firstCall.args.should.have.lengthOf(1);
queryString.stringify.firstCall.args[0].should.eql({
token: 'foo'
client_id: defaults.clientId,
token: 'foo',
client_secret: defaults.clientSecret
});
queryString.stringify.restore();
}));

it('should return an error if `token` is missing', inject(function($httpBackend, OAuth) {
var data = queryString.stringify({
token: undefined
client_id: defaults.clientId,
token: undefined,
client_secret: defaults.clientSecret
});

$httpBackend.expectPOST(defaults.baseUrl + defaults.revokePath, data)
Expand All @@ -407,7 +413,9 @@ describe('OAuthProvider', function() {
OAuthToken.setToken({ token_type: 'bearer', access_token: 'foo', expires_in: 3600, refresh_token: 'bar' });

var data = queryString.stringify({
token: 'bar'
client_id: defaults.clientId,
token: 'bar',
client_secret: defaults.clientSecret
});

$httpBackend.expectPOST(defaults.baseUrl + defaults.revokePath, data)
Expand Down

0 comments on commit 5518ed1

Please sign in to comment.