function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
PJ PillaiPJ Pillai 

LWC and Named Credentials

Hello,

I already know how to use Named Credentials in Apex however I need to know if LWC support Named Credentials.

I'm calling a external rest service from LWC and I need to pass on Authorization header. This credentials is stored as Named Credential. Stored crdentials in the custome object is security issue. 

Thanks,
PJP
Ajay K DubediAjay K Dubedi
Hi PJ,

For LWC Named credentials callouts go through below link it may helpful for you.

https://www.developer.atsiro.com/2019/01/24/lwc-part-4/
https://rajvakati.com/2019/02/12/how-to-call-soap-callouts-in-lightning-web-components/

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks,
Ajay Dubedi
PJ PillaiPJ Pillai
Thanks for info Ajay!.

However, the link you posted is not helpfull because as I said in my post, I need to call external rest service directly from LWC (JavaScript layer using Fetch API) and not from Apex class.  It is mulit-part file upload. Salesforce enforces some limitation on the file size if you go throrugh Apex. My solution will be accessing the service directly from LWC since there could be large file uploads.

I wanted to know if LWC supports Named Credentials. 

Thanks again.
 
Igor Vasylevskyi 12Igor Vasylevskyi 12
PJ, did you find the solution?
Marcos LasoMarcos Laso
I had similar requirements. I ended up storing crendetials encrypted in an user field and doing the oauth process mannually. I created an idea (https://trailblazer.salesforce.com/ideaView?id=0874V0000015K9YQAU) for this topic. Some votes would be nice