他们编写:“支持的平台:可移植类库”。 但后来我写的便携类这段代码中,我有一个错误:在便携库中使用Google API的.NET客户端库
public async void MyFuncrion()
{
UserCredential credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(
//new FileStream("client_secrets.json", FileMode.Open, FileAccess.Read),
new ClientSecrets
{
ClientId = "", //"PUT_CLIENT_ID_HERE",
ClientSecret = "" //"PUT_CLIENT_SECRETS_HERE"
},
new[] { TasksService.Scope.Tasks },
"user",
CancellationToken.None);
var service = new TasksService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "Tasks API Sample",
});
TaskLists results = await service.Tasklists.List().ExecuteAsync();
foreach (var tasklist in results.Items)
{
TasklistTitlesCollection.Add(tasklist.Title + " " + tasklist.Updated);
// You can get data from the file (using file.Title for example)
// and append it to a TextBox, List, etc.
}
}
错误的位置:“UserCredential credential = await GoogleWebAuthorizationBroker.AuthorizeAsync()
”,他doen't便携式图书馆工作。我怎样才能使用库,得到没有GoogleWebAuthorizationBroker
的任务。我已经获得自己的访问令牌,我只需要TasksService
,也许我可以通过我的访问令牌和其他在构造函数TasksService
?
有什么错误讯息?您是否通过NuGet安装Google API? –
当前上下文中不存在名称'GoogleWebAuthorizationBroker'。 – Denis
等问题。我无法将我的StorageDataStore实现交给GoogleWebAuthorizationBroker。 GoogleWebAuthorizationBroker没有这个参数。 https://developers.google.com/api-client-library/dotnet/guide/aaa_oauth – Denis