I am developing a Lightning Web Component that uses the Bulk API 2.0 to insert a large amount of data to Salesforce, exposing the functionality to non-technical users without access to the Setup.
So far, when the user uploads a CSV using a
Although all of this was achieved by hardcoding the bearer token I obtained by requesting a POST call to a Connected App that granted the API Access, since in the user context of Lightning Experience, API Access is not enabled as far as I know.
So my question would be, how can I best request an access token from the front-end of my LWC so I can call the API? Without having to hardcode sensitive information such as client secrets, passwords, etc. and securing the received Bearer Token
Lastly, a few things I would like to make clear:
Using Apex Batch is not an option. Sending the information from the LWC to Apex is costy. You need to separate it in a lot of chunks because the maximum payload you can pass as a parameter to an Apex function is around 4 MB, after it gets converted to base64. We are working with ~130 MB of data, so creating one Async Apex Job for each chunk would block the Flex Queue with our jobs, and considering our production environment is shared with other applications, and the max number of Jobs you can have in the Flex Queue is 100, we can't go with this approach.
Using tools such as dataloader.io is neither an option, since these external tools are not allowed by our client.
I hope I made myself clear, please add a comment if you need more information, thanks.