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

Authenticate then open External URL from within Salesforce

I'm looking for some guidance after days of searching SF, forums, tralblazer, etc. I haven't worked in SF in a very long time.
In my mind what I need to do is simple, but everything I seem to find leads me down a path of complex development. Maybe I'm searching on the wrong terms. 

Here is what I'm trying to do. 
Use case - User needs to click a button(action, etc.) in a record to open to an externally hosted site to perform a task that ties to the SF record they're working in. On click, it would automatically authenticate to the site, pass initial values, and then open the web page in an iframe (preferable), or in a new browser window/tab with the initial values populated. 

Basic logic - (at least in JSON)
1. Authenticate - grant type is client credentials, returns a bearer token
2. Initialise a session - bearer token in header, returns a web sessionid
3. Display that session - bearer token in the header, sessionid appended to the end of a static external URL

The primary issue for me is the structure of this. Writing the code itself isn't really an issue. It's where to put it all and bring it all together.

I had thought this could all be in done in a VF page, but that doesn't seem to be the case. Some people recommend using Canvas, but that seems to be way over the top. 

Any help, guidance is greatly appreciated.

Best Answer chosen by Rudabaugh

You can use the "VF page action button"  to create an API call to authenticate users. Below is the flow:
  • Create a button on the VF page.
  • On Button Click, call Controller Method: authenticateUser().
  • authenticateUser() will create an API call to verify the details and response with the bearer token.
  • validate bearer token, and, generate another API for Session, a response received with a session token.
  • validate session token, allow users to navigate to view the respective page. 

I hope this helps. 


skype: gaurav62990