A 400 response means there is something wrong with your request. The response body often indicates what was wrong with the request.
You can display the response body in your code (in case of failure) and check what message/information it gives (to help you identify the reason of the issue).
As you are saying it used to work, a possibility is that someone in your company deleted/disabled the OAuth client that you are using (the OAuth Client Credentials Grant client) or generated a new Client Secret for this OAuth client.