I am developing console application that use to extract task and tasklist of user by providing username and password. I googled several time but not found any working code simple, My code is here:

       UserCredential credential;
       using (var stream = new FileStream("client_secrets.json", FileMode.Open,   FileAccess.Read))
        {
            credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
                GoogleClientSecrets.Load(stream).Secrets,
                new[] { TasksService.Scope.Tasks },
                "shyam.sundar@gmai.com", CancellationToken.None, new FileDataStore("Tasks.Auth.Store")).Result;
        }            
       //credential=new UserCredential(
        // Create the service.
        var service = new TasksService(new BaseClientService.Initializer()
        {
            HttpClientInitializer = credential,
            ApplicationName = "Tasks API Sample",
        }); 
     ListTaskLists(service); //retun task list of user whose email is used to get secret key and id. It does not return task list of shyam.sudnar@gmail.com

Thanks Shyams

有帮助吗?

解决方案

use valid email address. It will work

    UserCredential credential;
   using (var stream = new FileStream("client_secrets.json", FileMode.Open,   FileAccess.Read))
    {
        credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
            GoogleClientSecrets.Load(stream).Secrets,
            new[] { TasksService.Scope.Tasks },
            "shyam.sundar@gmail.com", CancellationToken.None, new FileDataStore("Tasks.Auth.Store")).Result;
    }            
   //credential=new UserCredential(
    // Create the service.
    var service = new TasksService(new BaseClientService.Initializer()
    {
        HttpClientInitializer = credential,
        ApplicationName = "Tasks API Sample",
    }); 
 ListTaskLists(service)
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top