public static void Main(string[] args) { // Display the header and initialize the sample. CommandLine.EnableExceptionHandling(); CommandLine.DisplayGoogleSampleHeader("Tasks API: E-Tag collision"); // Register the authenticator. var provider = new NativeApplicationClient(GoogleAuthenticationServer.Description); FullClientCredentials credentials = PromptingClientCredentials.EnsureFullClientCredentials(); provider.ClientIdentifier = credentials.ClientId; provider.ClientSecret = credentials.ClientSecret; var auth = new OAuth2Authenticator <NativeApplicationClient>(provider, GetAuthentication); // Create the service. var service = new TasksService(auth); // Run the sample code. RunSample(service, true, ETagAction.Ignore); RunSample(service, true, ETagAction.IfMatch); RunSample(service, true, ETagAction.IfNoneMatch); RunSample(service, false, ETagAction.Ignore); RunSample(service, false, ETagAction.IfMatch); RunSample(service, false, ETagAction.IfNoneMatch); CommandLine.PressAnyKeyToExit(); }
public static void Main(string[] args) { // Display the header and initialize the sample. CommandLine.EnableExceptionHandling(); CommandLine.DisplayGoogleSampleHeader("Tasks API"); // Register the authenticator. var provider = new NativeApplicationClient(GoogleAuthenticationServer.Description); FullClientCredentials credentials = PromptingClientCredentials.EnsureFullClientCredentials(); provider.ClientIdentifier = credentials.ClientId; provider.ClientSecret = credentials.ClientSecret; var auth = new OAuth2Authenticator <NativeApplicationClient>(provider, GetAuthorization); // Create the service. var service = new TasksService(auth); TaskLists results = service.Tasklists.List().Fetch(); CommandLine.WriteLine(" ^1Lists:"); foreach (TaskList list in results.Items) { CommandLine.WriteLine(" ^2" + list.Title); } CommandLine.PressAnyKeyToExit(); }
public static void Main(string[] args) { // Display the header and initialize the sample. CommandLine.EnableExceptionHandling(); CommandLine.DisplayGoogleSampleHeader("Tasks API"); // Register the authenticator. var provider = new NativeApplicationClient(GoogleAuthenticationServer.Description); FullClientCredentials credentials = PromptingClientCredentials.EnsureFullClientCredentials(); provider.ClientIdentifier = credentials.ClientId; provider.ClientSecret = credentials.ClientSecret; var auth = new OAuth2Authenticator <NativeApplicationClient>(provider, GetAuthorization); // Create the service. var service = new TasksService(auth); // Execute request: Create sample list. if (!ListExists(service, SampleListName) && CommandLine.RequestUserChoice("Do you want to create a sample list?")) { CreateSampleTasklist(service); } CommandLine.WriteLine(); // Execute request: List task-lists. ListTaskLists(service); CommandLine.PressAnyKeyToExit(); }
static void Main(string[] args) { // Initialize this sample. CommandLine.EnableExceptionHandling(); CommandLine.DisplayGoogleSampleHeader("URLShortener -- List URLs"); // Register the authenticator. var provider = new NativeApplicationClient(GoogleAuthenticationServer.Description); FullClientCredentials credentials = PromptingClientCredentials.EnsureFullClientCredentials(); provider.ClientIdentifier = credentials.ClientId; provider.ClientSecret = credentials.ClientSecret; var auth = new OAuth2Authenticator <NativeApplicationClient>(provider, GetAuthorization); // Create the service. var service = new UrlshortenerService(auth); // List all shortened URLs: CommandLine.WriteAction("Retrieving list of shortened urls..."); int i = 0; string nextPageToken = null; do { // Create and execute the request. var request = service.Url.List(); request.StartToken = nextPageToken; UrlHistory result = request.Fetch(); // List all items on this page. if (result.Items != null) { foreach (Url item in result.Items) { CommandLine.WriteResult((++i) + ".) URL", item.Id + " -> " + item.LongUrl); } } // Continue with the next page nextPageToken = result.NextPageToken; } while (!string.IsNullOrEmpty(nextPageToken)); if (i == 0) { CommandLine.WriteAction("You don't have any shortened URLs! Visit http://goo.gl and create some."); } // ... and we are done. CommandLine.PressAnyKeyToExit(); }
static void Main(string[] args) { // Display the header and initialize the sample. CommandLine.EnableExceptionHandling(); CommandLine.DisplayGoogleSampleHeader("Site Verification sample"); // Register the authenticator. var provider = new NativeApplicationClient(GoogleAuthenticationServer.Description); FullClientCredentials credentials = PromptingClientCredentials.EnsureFullClientCredentials(); provider.ClientIdentifier = credentials.ClientId; provider.ClientSecret = credentials.ClientSecret; var auth = new OAuth2Authenticator <NativeApplicationClient>(provider, GetAuthentication); // Create the service. var service = new SiteVerificationService(); RunVerification(service); CommandLine.PressAnyKeyToExit(); }