-1

I'm currently trying to work with an integration with an external API (Lansweeper). When trying to authenticate the API, I'm running into an issue where they authenticate through an external url (https://app.lansweeper.com/authorize-app/XXXXX) where you can login with their credentials. They would then redirect the page to a site (https://https://xxxxx.com/public/services/apexrest.com/authCallback?code=XXXXXX) is currently what I have. I have a RestResource that can get the code, but it currently generates a blank page. Is there a way to close the tab that is generated from this?

I'm also up for other methods for authenticating this.

The end goal I'm trying to do is to get Lansweeper asset data and populate a LWC on the Salesforce Assets record page on load, or even through a button click. To accomplish this, I was trying to connect to Lansweeper and get the data, but I've gotten stuck at the first step with authenticating.

2
  • I feel like this may be an X-Y Problem. You're describing a process for logging in to Lansweeper Cloud API in order to perform GraphQL queries, so presumably you would have built this as a Visualforce page, rather than trying to close the page. I think you may be trying to authenticate Salesforce in Lansweeper so that you can scan Salesforce? If so, that's a different process than you've outlined here. Can you please edit your question for clarity?
    – sfdcfox
    May 4, 2023 at 20:03
  • @sfdcfox I was trying to get Lansweeper data through the LWC - I was hoping to pass in a site + asset ID and do a graphql query (through apex) on the LWC page, get the data back, then populate some UI in LWC. I haven't been able to find a way to authenticate without using the redirect -> callout to get the code that is required to get the access token
    – Kevin Yao
    May 4, 2023 at 20:48

1 Answer 1

0

You're describing the web server login flow. What you'll want to do is have the LWC redirect to the Lansweeper URL with a callback URL to a visualforce page, which will receive the code, then redirect back to the LWC app.

You must log in to answer this question.

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