他们写道:“支持的平台:便携式类库”。但是后来我在可移植类中编写了这段代码,我有一个错误:
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()
”,他不在便携式库中工作。我如何使用库,在没有GoogleWebAuthorizationBroker
. 我自己已经获得了访问令牌,我只需要TasksService
,也许我可以在构造函数中通过我的访问令牌和其他令牌TasksService
?