1

We want to take code we developed in Salesforce and expose it as a REST web service an external application. The external system can use either Basic Authentication or OAuth 2.0 with grant_type=client_credentials to authorize calls to any REST service.

I tried calling the REST endpoint in Salesforce via Basic authentication and I get INVALID SESSION_ID error. I also tried oAuth with grant_type=client_credentials and I get unsupported_grant_type error. ( Note: I have configured OAuth 2 using connected app in Salesforce).

I have searched the Salesforce documentation. Am I missing some configuration in Salesforce?

1

Neither mode is supported. Basic Authentication is not supported at all, as it is essentially insecure, and while there are a number of OAuth modes supported, the only one that allows a password is the Password flow (grant_type=password), but this mode does not include Refresh Tokens, so your client will need to continually log in using the username and password when the session times out. This means that changing the username or password will result in your app being locked out, unlike every other OAuth mode.

| improve this answer | |
  • Thanks, @sfdcfox for your suggestion. – mangesh patil Oct 8 at 7:44
1

Neither Basic Auth nor client credentials grant type is supported by Salesforce for authorizing access to REST APIs (docs). In lieu of client credentials, Salesforce supports and recommends JWT Bearer flow. Both client credentials and JWT Bearer flows can be used to achieve the same goal of supporting no-user-present, machine-to-machine or application-to-application authorization context.

If your external application cannot be modified, you could route your web service calls through an API Gateway or similar middleware that understands Basic Auth or client credentials grant type. The middleware may be able to translate your payload to oAuth grant supported by Salesforce. Mulesoft is a Salesforce product that can do this.

| improve this answer | |
  • Thanks @idenigral for your help – mangesh patil Oct 8 at 7:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.