打开新推送通知渠道时出错

时间:2018-06-15 12:35:49

标签: c# google-drive-api

我的应用程序过去工作得很好,但是当我尝试通过Google Drive .NET SDK打开推送通知渠道时,昨天开始给我一个错误,错误是:

Failed to create channel [400]

Message[Failed to create channel] 
Location[ - ] 
Reason[invalidArgument] 
Domain[global]

您可以在此处查看我的代码:

public async Task<Channel> StartWebHookWatch(TokenResponse token, string userId, string channelId, string pageToken, string urlCallBack)
{
    var service = GetDriveService(token);
    var expireDate = DateTime.UtcNow.AddSeconds(604800); // 1 Week

     var channel = new Channel()
     {
       Id = channelId, // Just a Guid created with "Guid.NewGuid().ToString();"
       Token = userId, // Just a Id to bind the channel With My appUser
       Type = "web_hook",
       Address = urlCallBack, // Authorized Url
       Expiration = (long)expireDate.Subtract(new DateTime(1970, 1, 1, 0, 0, 0)).TotalMilliseconds
     };

     return await service.Changes.Watch(channel, pageToken).ExecuteAsync();
}

private DriveService GetDriveService(TokenResponse token)
    {
        return new DriveService(new BaseClientService.Initializer()
        {
            HttpClientInitializer = new UserCredential(
                new GoogleAuthorizationCodeFlow(
                    new GoogleAuthorizationCodeFlow.Initializer() { ClientSecrets = ClientSecret }),
                ClientSecret.ClientId, token),
            ApplicationName = AppName
        });
    }

我刚做了很多测试,我甚至找不到问题是什么问题...... 我很感激帮助解决这个问题,谢谢你们。

0 个答案:

没有答案