便携式类库中的Google身份验证

时间:2014-04-07 10:21:34

标签: c# .net windows authentication windows-phone-8

我为(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.
        }
    }
  1. 我想使用这个库来处理任务/书籍,但是 我想将UserCredential存储在windows conteiner中加密(在app文件夹中存储谷歌商店)
  2. 我如何自己克制UserCredential credential,如果没有设置GoogleWebAuthorizationBroker.AuthorizeAsync的返回值,我已经有了访问代码,想要过去吗?
  3. 谢谢!

0 个答案:

没有答案