Skip to content

Commit 523060e

Browse files
committed
Add client_id and client_secret on revoke_token
1 parent 6519e27 commit 523060e

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
@@ -181,9 +181,16 @@ function OAuthProvider() {
181181
*/
182182

183183
revokeToken() {
184-
var data = queryString.stringify({
184+
var data = {
185+
client_id: config.clientId,
185186
token: OAuthToken.getRefreshToken() ? OAuthToken.getRefreshToken() : OAuthToken.getAccessToken()
186-
});
187+
};
188+
189+
if (null !== config.clientSecret) {
190+
data.client_secret = config.clientSecret;
191+
}
192+
193+
data = queryString.stringify(data);
187194

188195
var options = {
189196
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)