Advertisement
Guest User

Untitled

a guest
Sep 9th, 2022
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.98 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Threading;
  4. using Google.Apis.Auth.OAuth2;
  5. using Google.Apis.Auth.OAuth2.Flows;
  6. using Google.Apis.Keep.v1;
  7. using Google.Apis.Oauth2.v2;
  8. using Google.Apis.Services;
  9.  
  10. namespace Testing
  11. {
  12.         class Program
  13.         {
  14.                 [Obsolete]
  15.                 static void Main(string[] args)
  16.                 {
  17.                         Console.WriteLine("Google API Sample");
  18.                         Console.WriteLine("====================");
  19.  
  20.                         Console.WriteLine(Oauth2Service.Scope.UserinfoEmail);
  21.                         Console.WriteLine(KeepService.Scope.KeepReadonly);
  22.  
  23.                         List<string> scopes = new()
  24.                         {
  25.                                 "email",
  26.                                 "profile",
  27.                                 KeepService.Scope.Keep,
  28.                                 KeepService.Scope.KeepReadonly,
  29.                         };
  30.  
  31.                         var credential = GoogleWebAuthorizationBroker.AuthorizeAsync(new ClientSecrets
  32.                         {
  33.                                 ClientId = "",
  34.                                 ClientSecret = ""
  35.                         },
  36.                                                           scopes,
  37.                                                           "user",
  38.                                                           CancellationToken.None).Result;
  39.                      
  40.                         var service = new KeepService(new BaseClientService.Initializer()
  41.                         {
  42.                                 HttpClientInitializer = credential,
  43.                                 ApplicationName = "OAuth 2.0 Sample",                              
  44.                         });
  45.                      
  46.                         var notes = service.Notes.List().Execute();
  47.                         Console.WriteLine(notes.Notes.Count);                        
  48.                 }
  49.         }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement