all files / express-stormpath/lib/okta/ password-grant.js

100% Statements 6/6
100% Branches 0/0
100% Functions 1/1
100% Lines 6/6
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25                                     
'use strict';
 
var xtend = require('xtend');
 
var requestExecutor = require('./request-executor');
 
function passwordGrant(config, userFormSubmission, callback) {
  var req = {
    url: config.org + 'oauth2/' + config.authorizationServerId + '/v1/token',
    method: 'POST',
    json: true,
    form: xtend({
      client_id: config.authorizationServerClientId,
      client_secret: config.authorizationServerClientSecret,
      grant_type: 'password',
      scope: 'openid profile offline_access'
    }, userFormSubmission)
  };
 
  requestExecutor(req, callback);
 
}
 
module.exports = passwordGrant;