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
André Murillo 9André Murillo 9 

Named Credentials on AppExchange App

Hi! I'm working on an app to publish on AppExchange. The app needs to connect to my app API to retrieve and update information within Salesforce.

I've created my Custom Named Credentials and connected with oAuth2 with my app, and I understand that I'll have to add this to a Package before publishing the app.

My question is: at what moment do I ask the user for the credentials and permission for Salesforce to access my app API? Do I have to create a setup page, show a login popup or something like that (and how?), or when needed (a request to my server is going to be made on APEX...) does Salesforce makes the redirection to my app for the user to login and then goes back to Salesforce website?

I have looked for the information on how this will work but haven't found a clear reference on this process/flow...

Thanks for your help!
 
Riley Griffin 123Riley Griffin 123

You will probably have to create a button with a javascript controller that creates a popup from your websites login page. And after the user logs in, you send those details back to Salesforce.

I do not think it is possible to do this through PB or flows. Maybe you could acheive something with LWC. See here example and on the drop down choose password input  (https://developer.salesforce.com/docs/component-library/bundle/lightning-input/example)
 

André Murillo 9André Murillo 9
Ok thanks, I'll try that way. In that case I'll have to set the named credentials (token, refresh token, ...) manually right?

And just to be clear: there's no way to trigger the OAuth flow for my Named Credentials programatically? If that's the case then I think Named Credentials for an app that is going to be distributed become not usefull...

Thanks for the help!