Skip to content

Commit 5518ed1

Browse files
committed
Merge pull request #71 from tinogomes/pullrequest
Add `client_id` and `client_secret` on revoke_token
2 parents b2a8974 + 523060e commit 5518ed1

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

src/providers/oauth-provider.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,16 @@ function OAuthProvider() {
184184
*/
185185

186186
revokeToken() {
187-
var data = queryString.stringify({
187+
var data = {
188+
client_id: config.clientId,
188189
token: OAuthToken.getRefreshToken() ? OAuthToken.getRefreshToken() : OAuthToken.getAccessToken()
189-
});
190+
};
191+
192+
if (null !== config.clientSecret) {
193+
data.client_secret = config.clientSecret;
194+
}
195+
196+
data = queryString.stringify(data);
190197

191198
var options = {
192199
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }

test/unit/providers/oauth-provider.spec.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,8 @@ describe('OAuthProvider', function() {
363363
queryString.stringify.callCount.should.equal(1);
364364
queryString.stringify.firstCall.args.should.have.lengthOf(1);
365365
queryString.stringify.firstCall.args[0].should.eql({
366+
client_id: defaults.clientId,
367+
client_secret: defaults.clientSecret,
366368
token: 'bar'
367369
});
368370
queryString.stringify.restore();
@@ -378,14 +380,18 @@ describe('OAuthProvider', function() {
378380
queryString.stringify.callCount.should.equal(1);
379381
queryString.stringify.firstCall.args.should.have.lengthOf(1);
380382
queryString.stringify.firstCall.args[0].should.eql({
381-
token: 'foo'
383+
client_id: defaults.clientId,
384+
token: 'foo',
385+
client_secret: defaults.clientSecret
382386
});
383387
queryString.stringify.restore();
384388
}));
385389

386390
it('should return an error if `token` is missing', inject(function($httpBackend, OAuth) {
387391
var data = queryString.stringify({
388-
token: undefined
392+
client_id: defaults.clientId,
393+
token: undefined,
394+
client_secret: defaults.clientSecret
389395
});
390396

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

409415
var data = queryString.stringify({
410-
token: 'bar'
416+
client_id: defaults.clientId,
417+
token: 'bar',
418+
client_secret: defaults.clientSecret
411419
});
412420

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

0 commit comments

Comments
 (0)