using System; using Google.Apis.Auth.OAuth2; using Google.Apis.Drive.v3; using Google.Apis.Services; using System.Collections.Generic; using System.IO; using System.IO.MemoryMappedFiles; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ConsoleApp1 { internal class Program { static async Task Main(string[] args) { ; var credentials = await GoogleCredential.FromFileAsync("key/mobileprice-389203-a6dc6ada2693.json", CancellationToken.None); var service = new DriveService(new BaseClientService.Initializer()); Console.WriteLine("success"); var metadata = new Google.Apis.Drive.v3.Data.File() { Name = "myfile.txt" }; //var mediacontent = new MemoryStream(System.IO.TextWriter("hello world")); //var uploadRequest = service.Files.Create(metadata, mediacontent, "text/plain"); var uploadRequest = service.Files.Create(metadata); uploadRequest.Fields = "id"; var file = uploadRequest.Execute(); Console.WriteLine($"File ID: {file.Id}"); Console.ReadKey(); } } } Exception: service drive exception http status code is un authorise request is missing required authorisation credential expected auth2 access token
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)