Apex callouts are being used to integrate Salesforce with SAP Concur.
- Named Credential is incompatible because Concur returns a 403 after token expiry, whereas SF expects a 401 to know when to refresh the token.
- Custom Metadata cannot be written to, so the access token can’t be refreshed and then stored back in the record. Also, it is only secured by RBAC.
- A managed package does not fit the use case.
- Custom Settings have a max field length of 255, and the token length is in the thousands of characters. Same security concern as metadata.
For an automated solution where a service account’s access token is stored and refreshed to be used for callouts initiated by the user without requiring them to authenticate, is a custom object with encrypted custom fields a viable (albeit far from ideal) solution?
The technical drawbacks include the fact that the token, which can range in the thousands of characters, will need to be split among a dozen or more fields, since encrypted fields have a 175-char max length, as well as the fact that it ties the integration to a specific data record.