/CometD.NetCore.Salesforce

CometD Salesforce Implementation.

Primary LanguageC#MIT LicenseMIT

CometD .NET Core implementation of Salesforce Platform events

Build status

This repo contains the CometD .NET Core implementation for Salesforce Platform events.

These events can be subscribed to and listened to by your custom Event Listener. The sample application of this library can be found here.

The solution contains the following:

  1. CometD.NetCore2.Salesforce Project

  2. DotNet Cli tool salesforce Project

Installation

  • To include this library inside of your project run nuget package installation
    PM> Install-Package CometD.NetCore2.Salesforce

Or

 dotnet add package CometD.NetCore.Salesforce
  • To Install Salesforce Cli tool globally run the following command:
 dotnet tool install salesforce -g

To verify the installation run:

 dotnet tool list -g

Usage of Salesforce dotnet cli tool

There are several ways to run this cli tool.

  1. From any location with Consumer Key and Secret provided
    salesforce get-tokens --key:{key} --secret:{secret} --login:https://login.salesforce.com --verbose:information
  1. Running the tool in the directory that contains appsettings.json file
    salesforce get-tokens --section Salesforce

Note: required configurations are as follows:

  "Salesforce": {
    "ClientId": "",
    "ClientSecret": "",
    "LoginUrl": ""
  }
  1. Running with Azure Vault

`appsettings.json

    "AzureVault": {
     "BaseUrl": "https://{name}.vault.azure.net/"
    },

Then run:

    salesforce get-tokens --verbose:debug

Or specify url within the dotnet cli tool like so:

    salesforce get-tokens --azure https://{name}.vault.azure.net/"

This tool will open web browser and will require you to log in with your credentials to Salesforce portal in order to retrieve the tokens.

Saleforce Setup

Video

  1. Sing up for development sandbox with Saleforce: https://developer.salesforce.com/signup.
  2. Create Connected App in Salesforce.
  3. Create a Platform Event.

Create Connected App in Salesforce

  1. Setup -> Quick Find -> manage -> App Manager -> New Connected App.
  2. Basic Info:

info

  1. API (Enable OAuth Settings): settings

  2. Retrieve Consumer Key and Consumer Secret to be used within the Test App

Create a Platform Event

  1. Setup -> Quick Find -> Events -> Platform Events -> New Platform Event:

event

  1. Add Custom Field

event

(note: use sandbox custom domain for the login to workbench in order to install this app within your production)

Use workbench to test the Event workbench

AuthApp

Use login instead of test Simple application that provides with Web Server OAuth Authentication Flow to retrieve Access Token and Refresh Token to be used within the application.

Special thanks to the following projects and contributors: