[HttpGet("/salesforce/callback")] // Note, this is same as redirect_uri above
        public async Task <string> Login(string code)
        {
            var token = await client.GetToken(code);

            // Note:  Once we have the access token, we can call the REST API same as with other flows.
            //  See:  https://ballardsoftware.com/introduction-to-the-salesforce-rest-api-using-postman/

            return($"You have the access token {token.AccessToken} - you can use this bearer token to call the Salesforce REST API");
        }
        public async Task StartAsync(CancellationToken cancellationToken)
        {
            appLifetime.ApplicationStarted.Register(OnStarted);
            appLifetime.ApplicationStopping.Register(OnStopping);
            appLifetime.ApplicationStopped.Register(OnStopped);

            logger.LogInformation("SalesforceStreamingService.StartAsync has been called.");

            logger.LogInformation("Authenticating with Salesforce...");
            var authToken = await salesforceClient.GetToken();

            logger.LogInformation("Enabling Bayeux protocol...");
            var options = new Dictionary <String, Object>
            {
                { ClientTransport.TIMEOUT_OPTION, readTimeOut }
            };
            var transport = new LongPollingTransport(options);

            // add the needed auth headers
            var headers = new NameValueCollection();

            headers.Add("Authorization", "OAuth " + authToken.AccessToken);
            transport.AddHeaders(headers);

            // only need the scheme and host, strip out the rest
            var    serverUri = new Uri(authToken.InstanceUrl);
            String endpoint  = String.Format("{0}://{1}{2}", serverUri.Scheme, serverUri.Host, sfOptions.StreamEndpoint);

            bayeuxClient = new BayeuxClient(endpoint, new[] { transport });

            logger.LogInformation("Handshaking with Salesforce stream...");
            bayeuxClient.handshake();
            bayeuxClient.waitFor(1000, new[] { BayeuxClient.State.CONNECTED });

            logger.LogInformation("Connected to Salesforce stream...");

            bayeuxClient.getChannel(sfOptions.Channel).subscribe(new Listener(logger));
            logger.LogInformation("Waiting for data from server...");
        }