I am trying to make a webservice call to an authorization server (OAuth 2.0) using the "client_credentials" grant type, but i receive a "System.CalloutException: Unable to fetch the OAuth token." when executing this code :
Http httpCls = new Http();
HttpRequest request = new HttpRequest();
request.setEndpoint('callout:FasstAPIGEE');
request.setMethod('POST');
When i check the logs , i find these lines, both the name and the Id of the named credential are NULL:
However, when i make the same call via Postaman or curl , it works and i am able to get the access_token
I am sharing with you ma configuration of the named and the external credentials
here is a screenshot of the test i performed in postman
And here the curl command i am using that also works
curl -X POST -u "a1***_x**:xNMq******Gl" -d "grant_type=client_credentials" https://auth.***/oidc/token
Any ideas how to resolve the issue ?
Read
onUserExternalCredential
SObject?