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.

2
  • Why not used named credentials? Commented Jan 8, 2019 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. Commented Jan 8, 2019 at 11:08

1 Answer 1

1

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

3
  • 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 Commented Jan 8, 2019 at 11:20
  • Can you please give me example of that? Commented Jan 8, 2019 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, Commented Jan 8, 2019 at 11:39

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