[英]Which nuget package contains the method GetSheetService()?
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?我想知道是否有包含 GetSheetService() 的 nuget 包,我找不到哪个是正确的包,有人知道吗? 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:这是cs文件的开始:
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. google .net 客户端库没有称为 get sheet 服务的方法。 I suspect you are copying this from someones code some places.
我怀疑你是从某些地方的某人代码中复制的。 The correct way to create a sheets service follows
创建sheet服务的正确方法如下
/// <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.从我的 google .net 客户端库示例项目中提取的代码。 Oauth2Authentication.cs)
Oauth2Authentication.cs)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.