C# 4.0 Can';t上传到谷歌云存储

C# 4.0 Can';t上传到谷歌云存储,c#-4.0,cloud,google-cloud-storage,C# 4.0,Cloud,Google Cloud Storage,正在尝试使用.Net的Google API客户端库将文件上载到Google云存储。这是我的密码。它运行正常,没有任何错误,但也不能完成任务。请告诉我这里缺少什么,或者这是解决这个问题的正确方法。谢谢 try { Google.Apis.Services.BaseClientService.Initializer init = new Google.Apis.Services.BaseClientService.Initializer();

正在尝试使用.Net的Google API客户端库将文件上载到Google云存储。这是我的密码。它运行正常,没有任何错误,但也不能完成任务。请告诉我这里缺少什么,或者这是解决这个问题的正确方法。谢谢

        try
        {
            Google.Apis.Services.BaseClientService.Initializer init = new Google.Apis.Services.BaseClientService.Initializer();
            init.ApiKey = "server-apps-API-KEY-HERE";
            init.ApplicationName = "Project Default Service Account";

            Google.Apis.Storage.v1.StorageService ss = new Google.Apis.Storage.v1.StorageService(init);

            Google.Apis.Storage.v1.Data.Object fileobj = new Google.Apis.Storage.v1.Data.Object();
            fileobj.ContentType = "image/jpeg";

            ///READ FILE
            string file = @"C:\Photos\TEST.jpg";

            System.IO.Stream j = new System.IO.FileStream(file,
                                  System.IO.FileMode.Open,
                                   System.IO.FileAccess.Read);

            //New File Name
            fileobj.Name = "TEST.jpg";

            Google.Apis.Storage.v1.ObjectsResource.InsertMediaUpload insmedia;
            insmedia = new Google.Apis.Storage.v1.ObjectsResource.InsertMediaUpload(ss, fileobj, "test-common", j, "image/jpeg");
            insmedia.Upload();
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
            Console.ReadLine();
        }

您尚未授权访问代码中任何位置的Google云存储。请看我的答案:来举例说明如何做到这一点