0

I am using LWC for integration my application. I need to get the Personal Access Token at runtime. Is that possible to get?

Presently, I hardcode Personal Access Token in my LWC application. like this:

Http.setRequestHeader("Authorization", 'Bearer XXXXXXXXXXXXXXX');

i have clientId, ClientSecret, username and password. can i do auth 2.0 with it?

I am not able to get the Personal Access Token.

  • Why not used named credentials? – Pranay Jaiswal Jan 8 at 10:57
  • I am not creating any class.i am just writing code in javascript file which is lwc component for authorization my application. – Vaishali Garg Jan 8 at 11:08
0

From the documentation of LWC:

You can’t make calls to Salesforce APIs other than LDS from JavaScript code.

You have to use APEX to make this callout. And even in Apex, it has to used named credentials. You can refer guide here.

SRC for documentation : https://developer.salesforce.com/docs/component-library/documentation/lwc/data_api_calls_apex

  • I am trying to integrate Asana with lwc. if I am hardcode access token then api call working fine with javascript. but not able to fetch Access token dynamically from asana. because of it auth 2.0 support – Vaishali Garg Jan 8 at 11:20
  • Can you please give me example of that? – Vaishali Garg Jan 8 at 11:38
  • I have no clue about asana, hence I cant help you, neither havent seen anyone integrate Asana with LWC yet so you are on your own for now, – Pranay Jaiswal Jan 8 at 11:39

Not the answer you're looking for? Browse other questions tagged or ask your own question.