Skip to content

Commit

Permalink
Add client_id and client_secret on revoke_token
Browse files Browse the repository at this point in the history
  • Loading branch information
tinogomes committed Feb 5, 2016
1 parent 6519e27 commit a4d139c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/providers/oauth-provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,14 @@ function OAuthProvider() {

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

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

var options = {
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
};
Expand Down
7 changes: 7 additions & 0 deletions test/unit/providers/oauth-provider.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ 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: default.clientId,
token: 'bar'
});
queryString.stringify.restore();
Expand All @@ -378,13 +379,17 @@ 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: default.clientId,
client_secret: default.clientSecret,
token: 'foo'
});
queryString.stringify.restore();
}));

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

Expand All @@ -407,6 +412,8 @@ describe('OAuthProvider', function() {
OAuthToken.setToken({ token_type: 'bearer', access_token: 'foo', expires_in: 3600, refresh_token: 'bar' });

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

Expand Down

0 comments on commit a4d139c

Please sign in to comment.