我为(WIndows Store,Windows Phone,Windows)编写便携式应用程序。我使用便携式类库。 我看到google make tasks api库(WIndows Store,Windows Phone,Windows)。但我的谷歌认证有问题。
此代码在便携式库中不起作用(它适用于Windows Phone):
private ObservableCollection<string> _tasklistTitlesCollection = new ObservableCollection<string>();
public ObservableCollection<string> TasklistTitlesCollection
{
get { return _tasklistTitlesCollection; }
set { _tasklistTitlesCollection = value; }
}
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
,如果没有设置GoogleWebAuthorizationBroker.AuthorizeAsync
的返回值,我已经有了访问代码,想要过去吗?谢谢!