Create A Connected App in Salesforce
This article covers how to create a Connected App within Salesforce to allow OAuth flow with the Windward Maestro for Salesforce Application.
Before setting up a Connected App in Salesforce, you need to have an instance of the Windward Maestro for Salesforce application created and deployed on the web.
[Insert link to this pre-req article]
Navigating to the Connected App Creation Page
First off, log into your Salesforce account and navigate to the Setup section. This can be found in the top right portion of the Home page after you log in. If its not on the header bar, then click on your account name drop down and it should be located there.
After you are in the Setup page, on the left panel will be a category called App Setup and under that is an expandable category called Create. Under Create is a link called Apps. Click on that.
At the bottom of the page is a section called Connected Apps. Go ahead and click New.
Creating the Connected App
At this point you should be on the New Connected App page with a bunch of fields to fill out. We will only need to fill out a few! First, give your Connected App a name. It doesn't matter what this is, just something that will be easily identifiable by you and your organization. Next, under the API (Enable OAuth Settings) section, click the checkbox Enable OAuth Settings. This will then expand and give you a list of items you can chose for your OAuth scope as well as provide a Callback URL.
In the Callback URL box, enter the URL of your web instance of the Windward Maestro for Salesforce. And under the Available OAuth Scopes, select Full access (full) and click the add arrow to the right to add it to Selected OAuth Scopes. Do this same action for Perform requests on your behalf at any time (refresh_token, offline_access) and Access and manage your data (api). Your Selected OAuth Scopes should look like:
After that, that should be everything. Make sure you have a Connected App Name, Enable OAuth Settings selected, have a Callback URL entered as well as those 3 OAuth Scopes selected. If you do, click Save at the bottom of the page.
Linking Connected App to your Windward Maestro for Salesforce App
Now that your Connected App is setup, we need to add some info to the configuration of the Windward Maestro for Salesforce App to have OAuth work correctly. First, go to your Connected App info page within Salesforce. Under the API (Enable OAuth Settings) section should be a Consumer Key, Customer Secret and Callback URL. These are the 3 pieces of info we need to provide to the web app.
Once you have these 3 things, navigate to the appsettings.json file within your instance of the Windward Maestro for Salesforce App and you should find under the OAuthConfig portion, that there are 3 values that need to be entered: ClientId, ClientSecret, and RedirectUri. For ClientId, put in the Consumer Key. For ClientSecret enter the Client Secret and for RedirectUri enter the Callback URL.
Note that my values are just made up here, but you should have long random strings of characters for ClientId and ClientSecret, and then your Callback URL in RedirectUri
After you have entered that information, make sure to save the appsettings.json file. After that you're instance of the Windward Maestro for Salesforce app should be all setup with OAuth!