Salesforce OAuth2 Web Server Flow Example
This example is to complement a blog post available at (post link coming soon) which outlines how to use the Web Server Flow method of OAuth authentication with Salesforce, .NET Core, and ngrok.
- .NET Core 2.1+
- VS Code
- Salesforce Developer Account
- Salesforce Connect App Client Id and Secret
- Supporting Blog Post (coming soon)
Once you have setup your Salesforce Developer account, and defined the 'Connected App', update appsettings.json file with your client-id and client-secret. Note: You should convert this to use user-secrets in development, and environment variables and/or azure key vault in production to ensure security.
Once settings are updated, crun the following commands from your favorite command console. Mine is ConEmu.
dotnet build dotnet run
Below is an example diagram from Salesforce that outlines how the flow works. In our demo application, this follow happens inside the SalesforceController.cs and you can start your code navigation from there.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.