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.

A.K.
  • 708
  • 1
  • 8
  • 19
Vaishali Garg
  • 89
  • 2
  • 9

1 Answers1

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

Pranay Jaiswal
  • 35,996
  • 16
  • 75
  • 134
  • 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 08 '19 at 11:20
  • Can you please give me example of that? – Vaishali Garg Jan 08 '19 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 08 '19 at 11:39