-
Notifications
You must be signed in to change notification settings - Fork 976
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
System.CalloutException: Web service callout failed: WebService returned a SOAP Fault: INSUFFICIENT_ACCESS: use of the Metadata API requires a user with the ModifyAllData permission #44
Comments
Yeah unfortunately this does not extend to the metadata API. More so that in effect these classes are making http callouts, so the web service does not really even know what language the caller is using. Some suggestions would be to use some kind of queue for the work read by a scheduled job. Or using a oAuth token obtained from a admin user. |
Thanks Andrew. I need the action to be performed immediately hence I cant use scheduled job. Do you have any sample code with oAuth? |
When you create the MetadataService you can set either a Session ID or an oAuth Token.
The answers on this StackExchange question gives you the details on how to obtain either a Session Id (see my answer) or an oAuth token (see Phil Hawthorns answer). Note: The oAuth tokens are typically more persistent (you don't need to keep asking for them), as the idea is the admin can expire the callers access through the Connected App (which is your code in this context). However i am not 100% sure if this is true for the user name and password flow tbh. |
Do let me know how you get on with this. You should blog or tweet about it if you get it working, i know that others using this library would be interested. We could perhaps update the MetadataServiceExamples.cls as well? |
I am able to get the Oauth token using below. |
But now my look out is to get List View Id using medata api. Though I am able to get columns, filters from readMetadata it still doesn't retrieve id. If you see getListViewOptions() of StandardSetController it provides id, label..... And in the workbench as well under "Metadata Types & Components" ==> "List Views" we are able to view id's. |
Excellent glad you got it working! RE: ListView Id's. I think that might be using the listMetadata call? The FileProperties type returns the Id. |
Thanks Andrew. File Properties provides the id of the list view along with full name.It fetches list views from entire org on all objects. I have two questions on this
|
The main limit would be the 3MB limit on callout response sizes and maybe timeout if Salesforce doesn't respond in time. I did have a look at the Tooling API btw, no joy with that. Can you use dynamcially create a StandardSetController in your use case? |
Hi Andrew, I've the below scenario, please give me your inputs on this, I'm updating the CustomLabels as System administrator profile using VF page UI and I need to allow "Salesforce Platform" license profile users to update the custom labels using VF page. I have given the access to VF page, controller class and MetadataService class, but when I load VF page getting error as "WebService returned a SOAP Fault: INSUFFICIENT_ACCESS: use of the Metadata API requires a user with the ModifyAllData permission faultcode=sf:INSUFFICIENT_ACCESS faultactor=". Is there any option to allow Salesforce Platform profile's users to update the Customlabels? please advise. In case if we don't have option then I wish to try this as per below approach, As @sfdcprs I'll write apex rest API to get the customlabels using autotoke (System Admin credentials) and implement the logic to update the custom labels. Thanks in advance, |
Sorry, its a requirement of the Salesforce Metadata API to have this, as its a very powerful API. Yes you can use oAuth to have the admin authenticate that the code can use their access on behalf of the running user. But be very careful where you store this token. I would not recommend using the user/pass oAuth flow (as shown by @sfdcprs above) as you will need to store those some place for your code to read them which also presents a security risk of them being found. The web based oauth flow is unfortunately harder to implement and i don't have a clean example at hand. Here is another thought.... why don't you stage the changes to the labels in a custom object, then have a job / page the admin user can run that processes them every now and again? Its not as elegant and realtime i know, but is a separate of responsibilities. |
Hello, |
There was an unexpected error in your org which is preventing this assessment check from completing: System.CalloutException: Read timed out. |
Hi Andrew,
I am facing below exception when I log in as non admins. It works well for Sysadmin.
System.CalloutException: Web service callout failed: WebService returned a SOAP Fault: INSUFFICIENT_ACCESS: use of the Metadata API requires a user with the ModifyAllData permission.
Apex runs in system mode how does Metadata API taking the permission of the user. Can you please help me in understanding this.
Thank you in advance.
The text was updated successfully, but these errors were encountered: