小编Dim*_*ima的帖子

GmailService创建Watch()获取用户未经授权的错误

这个代码snniped:

  credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
                GoogleClientSecrets.Load(stream).Secrets,//read from client secret.json file
                Scopes,
                "user",
                CancellationToken.None).Result;

   // Create Gmail API service.
   var service = new GmailService(new BaseClientService.Initializer()
   {
      HttpClientInitializer = credential,
      ApplicationName = ApplicationName,
   });

   UsersResource.LabelsResource.ListRequest request = service.Users.Labels.List("me");
   WatchRequest body = new WatchRequest()
        {
            TopicName = "projects/push-notifications-ver3/topics/mytopic",
            LabelIds = new[] {"INBOX"}
  string userId = "me";
  UsersResource.WatchRequest watchRequest = service.Users.Watch(body, userId);
  WatchResponse test = watchRequest.Execute();
Run Code Online (Sandbox Code Playgroud)

获取错误:将测试消息发送到Cloud PubSub项目/ push-notifications-ver3/topics/mytopic时出错:用户未被授权执行此操作.[403]

主题是通过订阅创建的,作为主题的所有者给予当前用户许可任何建议用户未授权的原因?

c# google-api gmail-imap gmail-api google-cloud-pubsub

6
推荐指数
1
解决办法
832
查看次数

在循环中异步调用委托

我需要为同一个函数调用异步数量的委托.问题是我应该如何对待回调功能?我们有几个代理运行,所以CallbackMethod并不意味着所有异步委托都完成了.

AsyncMethodCaller c = new AsyncMethodCaller(instance.dummyMethod);
for (int i = 0; i < 100; i++)
    {
        IAsyncResult res = c.BeginInvoke(5000,
            out dummy, 
            new AsyncCallback(CallbackMethod),
            "executed on thread {0}, with result value \"{1}\".");
}
Run Code Online (Sandbox Code Playgroud)

.net c# delegates asynchronous

5
推荐指数
1
解决办法
76
查看次数