Skip to content

Commit 9499045

Browse files
committed
updated readme file and resolve issue #2
1 parent 4672e83 commit 9499045

5 files changed

Lines changed: 87 additions & 33 deletions

File tree

README.md

Lines changed: 60 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,78 @@
11
# CometD .NET Core implementation of Salesforce Platform events
22
[![Build status](https://ci.appveyor.com/api/projects/status/baalfhs6vvc38icc?svg=true)](https://ci.appveyor.com/project/kdcllc/cometd-netcore-salesforce)
33

4-
This repo contains the CometD .NET Core implementation for Salesforce Platform events.
5-
These events can be subscribed to and listened to by your custom `Event Listener`.
4+
This repo contains the CometD .NET Core implementation for Salesforce Platform events.
5+
6+
These events can be subscribed to and listened to by your custom `Event Listener`. The sample application of this library can be found [here](https://github.com/kdcllc/Bet.BuildingBlocks.SalesforceEventBus).
67

7-
1. `CometD.NetCore2.Salesforce`
8-
- Salesforce Platform Events as Event Bus [eShopOnContainers](https://github.com/dotnet-architecture/eShopOnContainers).
8+
The solution contains the following:
9+
10+
1. `CometD.NetCore2.Salesforce` Project
11+
- A Salesforce Platform Events implementation based [Even Bus idea of eShopOnContainers](https://github.com/dotnet-architecture/eShopOnContainers).
912
- [Reusable Building Blocks and sample application that listens to Salesforce push events](https://github.com/kdcllc/Bet.BuildingBlocks.SalesforceEventBus).
10-
2. DotNet Cli tool `AuthApp`
11-
- This dotnet cli tool allows for retrieval of `Access Token` and `Refresh Token` to be used by any other application. Please refer to [How Are Apps Authenticated with the Web Server OAuth Authentication Flow](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/intro_understanding_web_server_oauth_flow.htm)
1213

14+
2. DotNet Cli tool `salesforce` Project
15+
- This dotnet cli tool allows for retrieval of `Access Token` and `Refresh Token` to be used by any other application. Please refer to [How Are Apps Authenticated with the Web Server OAuth Authentication Flow](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/intro_understanding_web_server_oauth_flow.htm)
1316

1417
## Installation
1518

1619
- To include this library inside of your project run nuget package installation
17-
> Install-Package CometD.NetCore2.Salesforce
20+
21+
```cmd
22+
PM> Install-Package CometD.NetCore2.Salesforce
23+
```
24+
1825
Or
19-
> dotnet add package CometD.NetCore.Salesforce
20-
- To Inatall Salesforce Cli tool globally
2126

22-
> dotnet tool install salesforce -g
27+
```cmd
28+
dotnet add package CometD.NetCore.Salesforce
29+
```
30+
31+
- To Install Salesforce Cli tool globally run the following command:
32+
33+
```cmd
34+
dotnet tool install salesforce -g
35+
36+
```
37+
38+
To verify the installation run:
39+
40+
```cmd
41+
dotnet tool list -g
42+
```
43+
44+
## Usage of Salesforce dotnet cli tool
45+
46+
The regular usage of this tool is within the Salesforce project that utilizes this library and contains configuration settings with the minimum of:
47+
48+
```json
49+
"Salesforce": {
50+
"ClientId": "",
51+
"ClientSecret": ""
52+
}
53+
````
54+
55+
Or you can specify Azure Key Vault Url:
56+
57+
```json
58+
"AzureVault": {
59+
"BaseUrl": "https://{name}.vault.azure.net/"
60+
},
61+
```
62+
63+
Then run:
64+
65+
```cmd
66+
salesforce get-tokens
67+
```
2368

24-
Then to see if it was installed correctly:
69+
Or specify url within the dotnet cli tool like so:
2570

26-
> dotnet tool list -g
71+
```cmd
72+
salesforce get-tokens --azure https://{name}.vault.azure.net/"
73+
```
2774

28-
## Salesforce DotNet Cli usage
29-
Run this in the project directory that contains appsettings.json with your setttings:
30-
> salesforce refresh-token
31-
It will open web browser and log in with your credentials.
75+
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.
3276

3377
## Saleforce Setup
3478
[Video](https://www.youtube.com/watch?v=L6OWyCfQD6U)

build/settings.props

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010
</PropertyGroup>
1111

1212
<PropertyGroup Label="Nuget Package Settings">
13-
<Description>Event Bus for Salesforce Platform events.</Description>
14-
<PackageProjectUrl>https://github.com/kdcllc/CometD.NetCore.Salesforce</PackageProjectUrl>
15-
<RepositoryUrl>https://github.com/kdcllc/CometD.NetCore.Salesforce.git</RepositoryUrl>
13+
<Description>Event Bus for Salesforce Platform events.</Description>
14+
<PackageProjectUrl>https://github.com/kdcllc/CometD.NetCore.Salesforce</PackageProjectUrl>
15+
<RepositoryUrl>https://github.com/kdcllc/CometD.NetCore.Salesforce.git</RepositoryUrl>
1616
<RepositoryType>git</RepositoryType>
17-
<PackageLicense>https://github.com/kdcllc/CometD.NetCore.Salesforce/blob/master/LICENSE</PackageLicense>
18-
<PackageIconUrl>https://raw.githubusercontent.com/kdcllc/CometD.NetCore.Salesforce/master/img/logo64x64.png</PackageIconUrl>
17+
<PackageLicense>https://github.com/kdcllc/CometD.NetCore.Salesforce/blob/master/LICENSE</PackageLicense>
18+
<PackageIconUrl>https://raw.githubusercontent.com/kdcllc/CometD.NetCore.Salesforce/master/img/logo64x64.png</PackageIconUrl>
1919
<PackageTags>aspnetcore,dottet,salesforce, cometd, bayeux</PackageTags>
2020
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
2121
</PropertyGroup>

src/AuthApp/AuthApp.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<TargetFrameworks>netcoreapp2.2;</TargetFrameworks>
66
<ToolCommandName>salesforce</ToolCommandName>
77
<PackageId>salesforce</PackageId>
8-
<Description>A command-line tool that enables Salesforce Refresh Token Generation.</Description>
8+
<Description>A command-line tool that enables Salesforce Access and Refresh Tokens Generation.</Description>
99
<PackAsTool>True</PackAsTool>
1010
</PropertyGroup>
1111

src/AuthApp/Properties/launchSettings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"profiles": {
33
"AuthApp": {
44
"commandName": "Project",
5-
"commandLineArgs": "refresh-token --azure https://kdcllc.vault.azure.net/ --configfile D:\\Dev\\GitHub\\kdcllc\\CometD.NetCore.Salesforce\\src\\TestApp\\appsettings.json --verbose"
5+
"commandLineArgs": "refresh-token --azure https://{name}.vault.azure.net/"
66
}
77
}
88
}

src/AuthApp/TokenGeneratorCommand.cs

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
using AuthApp.Host;
2+
using Bet.AspNetCore.Options;
23
using McMaster.Extensions.CommandLineUtils;
34
using Microsoft.Extensions.DependencyInjection;
45
using Microsoft.Extensions.Hosting;
6+
using System;
57
using System.Threading.Tasks;
68
namespace AuthApp
79
{
8-
[Command("refresh-token",
9-
Description ="Generates Salesforce Refresh Token",
10+
[Command("get-tokens",
11+
Description = "Generates Salesforce Access and Refresh Tokens",
1012
ThrowOnUnexpectedArgument = false)]
1113
internal class TokenGeneratorCommand
1214
{
@@ -41,15 +43,23 @@ private async Task<int> OnExecuteAsync()
4143
HostingEnviroment = !string.IsNullOrWhiteSpace(HostingEnviroment) ? HostingEnviroment : "Development"
4244
};
4345

44-
var builder = HostBuilderExtensions.CreateDefaultBuilder(builderConfig)
45-
.ConfigureServices((hostingContext,services) =>
46-
{
47-
services.ConfigureWithDataAnnotationsValidation<SfConfig>("Salesforce");
48-
services.AddHostedService<HttpServer>();
49-
});
46+
try
47+
{
48+
var builder = HostBuilderExtensions.CreateDefaultBuilder(builderConfig)
49+
.ConfigureServices((hostingContext, services) =>
50+
{
51+
services.ConfigureWithDataAnnotationsValidation<SfConfig>("Salesforce");
52+
services.AddHostedService<HttpServer>();
53+
});
54+
55+
await builder.RunConsoleAsync();
56+
return 0;
57+
}
58+
catch (Exception)
59+
{
60+
throw;
61+
}
5062

51-
await builder.RunConsoleAsync();
52-
return 0;
5363
}
5464
}
5565
}

0 commit comments

Comments
 (0)