Ejemplo n.º 1
0
        public static async Task Go()
        {
            //notasecret
            //sismmar-sisges-d3f15fa8366e.p12

            string[] scopes = new string[] { DriveService.Scope.Drive }; // Full access
            var keyFilePath = @"C:\Users\m.lourenco\Downloads\sismmar-sisges-d3f15fa8366e.p12";    // Downloaded from https://console.developers.google.com 
            var serviceAccountEmail = "*****@*****.**";  // found https://console.developers.google.com 


            //loading the Key file 
            var certificate = new X509Certificate2(keyFilePath, "notasecret", X509KeyStorageFlags.Exportable);
            var credential = new ServiceAccountCredential(new ServiceAccountCredential.Initializer(serviceAccountEmail)
            {
                Scopes = scopes
            }.FromCertificate(certificate));

            // Create the service.
            var service = new DriveService(new BaseClientService.Initializer()
            {
                HttpClientInitializer = credential,
                ApplicationName = "Drive API Sample",
            });

            service.CreateFolder("sismmar");
            service.ListFiles();

            Console.Read();
        }