I want to know whether there is a nuget package that contains GetSheetService(), I can't find which is the right package, anyone know this? Has anyone used this method?
This are the packages that I had installed:
<ItemGroup>
<PackageReference Include="Google.Apis" Version="1.40.3" />
<PackageReference Include="Google.Apis.Auth" Version="1.40.3" />
<PackageReference Include="Google.Apis.Auth.Mvc" Version="1.40.3" />
<PackageReference Include="Google.Apis.Sheets.v4" Version="1.40.3.1694" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.28" />
</ItemGroup>
and this is the problem I have encountered:
this is the start of the cs file:
using System;
using System.IO;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using Google.Apis.Sheets.v4;
The google .net client library does not have a method called get sheets service. I suspect you are copying this from someones code some places. The correct way to create a sheets service follows
/// <summary>
/// This method get a valid service
/// </summary>
/// <param name="credential">Authecated user credentail</param>
/// <returns>SheetsService used to make requests against the Sheets API</returns>
private static SheetsService GetService(UserCredential credential)
{
try
{
if (credential == null)
throw new ArgumentNullException("credential");
// Create Sheets API service.
return new SheetsService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "Sheets Oauth2 Authentication Sample"
});
}
catch (Exception ex)
{
throw new Exception("Get Sheets service failed.", ex);
}
}
}
Code ripped from my google .net client Library sample project. Oauth2Authentication.cs)