diff --git a/lib/grant-types/client-credentials-grant-type.js b/lib/grant-types/client-credentials-grant-type.js index e2db3f7c..211628d3 100644 --- a/lib/grant-types/client-credentials-grant-type.js +++ b/lib/grant-types/client-credentials-grant-type.js @@ -45,7 +45,7 @@ class ClientCredentialsGrantType extends AbstractGrantType { } const scope = this.getScope(request); - const user = this.getUserFromClient(client); + const user = await this.getUserFromClient(client); return this.saveToken(user, client, scope); } diff --git a/test/integration/grant-types/client-credentials-grant-type_test.js b/test/integration/grant-types/client-credentials-grant-type_test.js index 83de9f9a..1a70874e 100644 --- a/test/integration/grant-types/client-credentials-grant-type_test.js +++ b/test/integration/grant-types/client-credentials-grant-type_test.js @@ -93,14 +93,21 @@ describe('ClientCredentialsGrantType integration', function() { it('should return a token', function() { const token = {}; const model = { - getUserFromClient: function() { return {}; }, - saveToken: function() { return token; }, + getUserFromClient: async function(client) { + client.foo.should.equal('bar'); + return { id: '123'}; + }, + saveToken: async function(_token, client, user) { + client.foo.should.equal('bar'); + user.id.should.equal('123'); + return token; + }, validateScope: function() { return 'foo'; } }; const grantType = new ClientCredentialsGrantType({ accessTokenLifetime: 120, model: model }); const request = new Request({ body: {}, headers: {}, method: {}, query: {} }); - return grantType.handle(request, {}) + return grantType.handle(request, { foo: 'bar' }) .then(function(data) { data.should.equal(token); })