1

Is it possible to make tooling API calls from lightning components? I am getting 'This session is not valid for use with the REST API' error.

Reading a few articles online, seems there are some hacks of hosting component inside a VF page, or creating complex connected-app/named-credentials/oauth-flow.

Is there any optimized/simple solution to this problem? Thanks.

1 Answer 1

1

The documented solution is to use Named Credentials:

To call Salesforce APIs, make the API calls from your component’s Apex controller. Use a named credential to authenticate to Salesforce.

The Session Id exposed to your Aura Apex controllers is not API enabled.

Calling the Tooling API requires elevated privileges. Your Named Credential would be exposing the ability to make API calls as a privileged, likely System Administrator user account.

Both this security facet and the fact of calling the Tooling API itself, which can mutate some metadata in an active org, entails not-inconsiderable risks to your production Salesforce. Consider very carefully before proceeding with such an implementation, and take great care to validate all input thoroughly before making a Tooling API call.

4

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .