Looking at the code, I believe this is likely because your team is using content-type: application/json however, the content type for the get OAuth 2.0 access and refresh tokens endpoint is application/x-www-form-urlencoded. As documented here: Get OAuth 2.0 access and refresh tokens.
Could you either remove the header or change the header from application/json to application/x-www-form-urlencoded and see if it works?
Getting Unsupported Media Type Error while geting token
We are experiencing the same issue. We first experienced a media type error and used the direction from this post to resolve it by adding the JSON application content type. Now we're getting the unknown or missing grant type error.