Skip to content

Commit

Permalink
SDI-88: 🚨 Second attempt to querystring warning
Browse files Browse the repository at this point in the history
  • Loading branch information
petergphillips committed May 12, 2022
1 parent cd048c4 commit 6d0cb5d
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions server/data/hmppsAuthClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,18 @@ function getSystemClientTokenFromHmppsAuth(username?: string): Promise<superagen
config.apis.hmppsAuth.systemClientSecret
)

const grantRequest = { grant_type: 'client_credentials', ...(username && { username }) }
const grantRequest = new URLSearchParams({
grant_type: 'client_credentials',
...(username && { username }),
}).toString()

logger.info(
`HMPPS Auth request '${grantRequest}' for client id '${config.apis.hmppsAuth.systemClientId}' and user '${username}'`
)
logger.info(`${grantRequest} HMPPS Auth request for client id '${config.apis.hmppsAuth.systemClientId}''`)

return superagent
.post(`${hmppsAuthUrl}/oauth/token`)
.set('Authorization', clientToken)
.set('content-type', 'application/x-www-form-urlencoded')
.send(new URLSearchParams(grantRequest).toString())
.send(grantRequest)
.timeout(timeoutSpec)
}

Expand Down

0 comments on commit 6d0cb5d

Please sign in to comment.