These services from Google have been discontinued, and now they have come up with another service Google.Apis.Sheets.v4.
so the above code will not work now for several days, I have already tried.
And find something that worked for me.
I wrote a blog and shared all the source code. Check this.
private static SheetsService AuthorizeGoogleApp() { UserCredential credential; using (var stream = new FileStream("client_secret.json", FileMode.Open, FileAccess.Read)) { string credPath = System.Environment.GetFolderPath( System.Environment.SpecialFolder.Personal); credPath = Path.Combine(credPath, ".credentials/sheets.googleapis.com-dotnet-quickstart.json"); credential = GoogleWebAuthorizationBroker.AuthorizeAsync( GoogleClientSecrets.Load(stream).Secrets, Scopes, "user", CancellationToken.None, new FileDataStore(credPath, true)).Result; Console.WriteLine("Credential file saved to: " + credPath); }
For all source code, check it out. Paste a new row into Google Sheet using Google.Apis.Sheets.V4 services
source share