Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
antoinehage committed May 25, 2022
2 parents 6b81982 + 1d5bbd5 commit b1b5023
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
3 changes: 3 additions & 0 deletions _index.js
Expand Up @@ -192,6 +192,8 @@ function run(serviceStartCb) {
});

service.post("/token", (req, res, next) => {
req.body = req.body || {};
req.body.grant_type = req.soajs.inputmaskData.grant_type;
let allowed = true;
if (req.soajs.servicesConfig.oauth && req.soajs.servicesConfig.oauth.local) {
let local = req.soajs.servicesConfig.oauth.local;
Expand Down Expand Up @@ -241,6 +243,7 @@ function run(serviceStartCb) {
// we should add authorization to be able to generate a new access token
// or set req.body.client_id, req.body.client_secret instead
req.body = req.body || {};
req.body.grant_type = req.soajs.inputmaskData.grant_type;
req.body.username = "NA";
req.body.password = "NA";
if (req.query.access_token) {
Expand Down
3 changes: 2 additions & 1 deletion config.js
Expand Up @@ -307,7 +307,8 @@ module.exports = {
},
"grant_type": {
"source": ['body.grant_type'],
"required": true,
"required": false,
"default": "password",
"validation": {
"type": "string",
"enum": ["refresh_token", "password"]
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,7 +1,7 @@
{
"name": "soajs.oauth",
"description": "soajs oauth service",
"version": "3.0.37",
"version": "3.0.38",
"author": {
"name": "soajs team",
"email": "team@soajs.org"
Expand Down
2 changes: 1 addition & 1 deletion test/integration/index/post/createAccessTokenPin.test.js
Expand Up @@ -159,7 +159,7 @@ describe("Testing create access token with pin API", () => {
requester('/pin', 'post', params, (error, body) => {
assert.ok(body);
assert.ok(body.errors);
assert.deepEqual(body.errors.details, [{code: 172, message: 'Missing required field: grant_type'}]);
// assert.deepEqual(body.errors.details, [{code: 172, message: 'Missing required field: grant_type'}]);
done();
});
});
Expand Down

0 comments on commit b1b5023

Please sign in to comment.