public void Init() { // Use TLS 1.2 (instead of defaulting to 1.0) ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; _auth = new AuthenticationClient(); _auth.UsernamePasswordAsync(ConsumerKey, ConsumerSecret, Username, Password, TokenRequestEndpointUrl).Wait(); _toolingClient = new ToolingClient(_auth); }
private static async Task RunSample() { var auth = new AuthenticationClient(); // Authenticate with Salesforce Console.WriteLine("Authenticating with Salesforce"); var url = IsSandboxUser.Equals("true", StringComparison.CurrentCultureIgnoreCase) ? "https://test.salesforce.com/services/oauth2/token" : "https://login.salesforce.com/services/oauth2/token"; await auth.UsernamePasswordAsync(ConsumerKey, ConsumerSecret, Username, Password, url); Console.WriteLine("Connected to Salesforce"); var client = new ToolingClient(auth.InstanceUrl, auth.AccessToken, auth.ApiVersion); //Query existing Apex Classes Console.WriteLine("Get Classes"); string qry = "SELECT ID, Name FROM ApexClass"; var apexClasses = new List <ApexClass>(); var apexClassResults = await client.QueryAsync <ApexClass>(qry); var totalSize = apexClassResults.totalSize; Console.WriteLine("Queried " + totalSize + " records."); //Query existing Profiles //Query existing Apex Classes Console.WriteLine("Get Completions"); string type = "apex"; var completions = new Completions(); var completionResults = await client.CompletionsAsync <Completions>(type); Console.WriteLine("Queried " + totalSize + " records."); }