OAuth is a modern application authentication and authorization infrastructure that provides secure access to your application data. This is achieved through various mechanisms, one of which involves generating an access token. The token-based authentication is more secure than sharing user credentials directly with an application. A compromised token can be revoked at any time, and a new one can be created. Users can each have their own token with different access levels for each user. Another major benefit from an administration perspective is that, instead of keeping track of credentials, you can send the token file directly while providing the token password through a separate secure communication if needed.
Setting up an OAuth connection can be an involved process, as there are numerous steps that can be slightly confusing if you have not worked with the concept before.
This blog post will walk you through the process of creating a Salesforce app for OAuth, obtaining any necessary information, and setting up a Salesforce Connection Manager to connect to your Salesforce application for integration purposes.
Creating Salesforce App
- Log in to your Salesforce account and search for your App Manager in the Quick Find Box.
- In the App Manager, click on the “New Connected App” button.
- Give your app a name and a contact email. The name will be displayed in the App Manager. Please ensure that the name is unique within your organization.
- Next, under the API Tab, check the
Enable OAuth Settings. Make sure that you enter a callback URL. The callback URL is the same as the OAuth redirect URI. The callback URL is the URL to which the user is redirected after successful authorization. You can provide any valid HTTPS URL; however, ensure it is a URL without redirects.
- After this, you need to select the OAuth scopes to apply for the app. You can do this by selecting the available OAuth scopes and adding them to the right side. Make sure you are adding the appropriate OAuth scopes, as the OAuth scopes define the permissions that are granted for the app. In this example, we have given “Full access” and "Perform requests on your behalf at any time" scopes. The "Perform requests on your behalf at any time" scope is used to get a refresh token. The refresh token will help refresh your access automatically, so you don't have to re-authenticate every time.
- Lastly, click Save. You have successfully created your Salesforce app.
Getting Client ID and Client Secret
- To get your client credentials, you need to go back to your App Manager. You can then go to the App that you just created. Click on the drop-down menu and select " View".
- This will allow you to open the app and view all its settings and configurations.
It will show the Scopes that you have given the app and the Callback URL.
- Next, press the Manage Consumer Details; it will take you to another page showing the Consumer Key and Secret. You may be required to validate your identity. Salesforce will send a verification code to your email.
Configuring Salesforce Connection Manager In SSIS
After completing the steps above, you may now head to your SSIS development environment to create your Salesforce Connection.
Our Salesforce Connection Manager supports both SOAP and REST Service Endpoints to connect with the Salesforce API. However, in this instance, we will be using REST. You will then need to provide the Instance Type. There are three options available:
- Production
- Sandbox
- Other: this Instance Type would be used when the Service URL we generate in the Service URL window does not fully match the instance you want to connect to. In this case, the field is unlocked for editing.
Finally, we will set the authentication type to AuthorizationCode.
You will then click "Get New Token" and enter the details from the previous steps to authorize and generate the token.
Since we created a Salesforce App earlier in the blog post, we will use the option My Own App. The KingswaySoft App is a publicly shared app that we provide for testing purposes; however, it is not recommended for production use.
- Client ID: You can find the client ID in step 9 as the Consumer Key.
- Client Secret: You can find the Client Secret in step 9 as the Consumer Secret.
- Redirect URl: The URI was provided in step 4 as the Callback URL.
Please note that your Salesforce Administrator has enabled the Require Proof Key for Code Exchange (PKCE) Extension on an Org-wide level, or you can select the Require Proof Key for Code Exchange (PKCE) extension when creating the Salesforce app.
After clicking OK, you will be prompted to log into your Salesforce account, which will then redirect you to your redirect URL. The URL will contain a code. You need to copy the entire URL and paste it into the component.
Finally, you will be prompted to set a password for the token file before it is saved. After this, the process will be completed. You can test the connection using the "Test Connection" button to verify if you can access the instance. Press OK to save the configuration you have created.
Closing Notes
We hope this has been helpful. In this blog post, we have covered the setup for the app required in Salesforce, along with obtaining your client ID, client secret, and generating the token file in the Salesforce Connection Manager. We have also explained how OAuth works and the benefits of using it as an authentication method over legacy authentication. In this blog post, our focus was on the Authorization Code authentication type for OAuth; however, our component also supports the Certificate OAuth type. You can take a look at our help manual help manual for more information.