@@ -15,6 +15,15 @@ namespace AuthApp
1515 ThrowOnUnexpectedArgument = false ) ]
1616 internal class TokenGeneratorCommand
1717 {
18+ [ Option ( "--key" , Description = "The Salesforce Consumer Key." ) ]
19+ public string ClientId { get ; set ; }
20+
21+ [ Option ( "--secret" , Description = "The Salesforce Consumer Secret." ) ]
22+ public string ClientSecret { get ; set ; }
23+
24+ [ Option ( "--login" , Description = "The Salesforce login url. The default value is https://login.salesforce.com." ) ]
25+ public string LoginUrl { get ; set ; }
26+
1827 [ Option ( "--azure" ,
1928 Description = "Allows to specify Azure Vault Url. It overrides url specified in the appsetting.json file or any other configuration provider." ) ]
2029 public string AzureVault { get ; set ; }
@@ -57,25 +66,30 @@ private async Task<int> OnExecuteAsync()
5766 Verbose = Verbose . HasValue ,
5867 Level = Verbose . level ,
5968 UserSecrets = UserSecrets ,
60- HostingEnviroment = ! string . IsNullOrWhiteSpace ( HostingEnviroment ) ? HostingEnviroment : "Development"
69+ HostingEnviroment = ! string . IsNullOrWhiteSpace ( HostingEnviroment ) ? HostingEnviroment : "Development" ,
70+ Settings = new SfConfig
71+ {
72+ ClientId = ClientId ,
73+ ClientSecret = ClientSecret ,
74+ LoginUrl = ! string . IsNullOrWhiteSpace ( LoginUrl ) ? LoginUrl : "https://login.salesforce.com"
75+ } ,
76+ SectionName = string . IsNullOrWhiteSpace ( SectionName ) ? "Salesforce" : SectionName ,
6177 } ;
6278
6379 try
6480 {
6581 var builder = HostBuilderExtensions . CreateDefaultBuilder ( builderConfig )
6682 . ConfigureServices ( ( hostingContext , services ) =>
6783 {
68- var configSection = string . IsNullOrWhiteSpace ( SectionName ) ? "Salesforce" : SectionName ;
69-
70- services . ConfigureWithDataAnnotationsValidation < SfConfig > ( hostingContext . Configuration , configSection ) ;
84+ services . ConfigureWithDataAnnotationsValidation < SfConfig > ( hostingContext . Configuration , builderConfig . SectionName ) ;
7185 services . AddHostedService < HttpServer > ( ) ;
7286 } ) ;
7387
7488 await builder . RunConsoleAsync ( ) ;
7589
7690 return 0 ;
7791 }
78- catch ( Microsoft . Extensions . Options . OptionsValidationException )
92+ catch ( Microsoft . Extensions . Options . OptionsValidationException exv )
7993 {
8094 Console . WriteLine ( "Not all of the required configurations has been provided." , Color . Red ) ;
8195 }
0 commit comments