- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在编写一个 C# 桌面应用程序,可以将其输出复制到用户的 Google 云端硬盘。但是,当我尝试使用 GoogleWebAuthorizationBroker.AuthorizeAsync() 授权访问 Google 时,如果用户关闭浏览器中的身份验证页面,该方法将永远不会返回!
即使我使用 30 秒的取消 token ,如果浏览器关闭,它也不会返回。
public bool Authorise()
{
_authorised = false;
UserCredential credential = null;
try
{
// here is where we Request the user to give us access, or use the Refresh Token that was previously stored in %AppData%
CancellationTokenSource cts = new CancellationTokenSource(new TimeSpan(0,0,30));
credential = GoogleWebAuthorizationBroker.AuthorizeAsync(new ClientSecrets { ClientId = this.ClientId, ClientSecret = this.ClientSecret },
Scopes,
UserName,
cts.Token,//CancellationToken.None,
new FileDataStore(AppName)).Result;
}
catch (Exception)
{
return _authorised;
}
if ((credential != null) && (credential.Token.AccessToken != null))
{
Service = new DriveService(new BaseClientService.Initializer() { HttpClientInitializer = credential, ApplicationName = AppName, });
_authorised = true;
}
return _authorised;
}
如何捕获用户关闭浏览器窗口并停止我的应用程序挂起?
最佳答案
这是 Google .net 客户端库中的一个已知问题。
据我所知,目前没有解决方法。我建议将您的名字添加到论坛的问题中,以鼓励团队解决问题。
更新:它现在在列表中GoogleWebAuthorizationBroker does not honour CancellationToken when waiting for browser response
关于c# - 如果浏览器关闭,GoogleWebAuthorizationBroker.AuthorizeAsync() 会挂起,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43136455/
我正在学习 C#(为 Windows Phone 开发),并且我正在尝试对我的用户进行身份验证以进入 Google 的帐户。我正在使用这段代码: https://developers.google.c
我尝试使用 youtube api v3 和 .NET 将视频上传到 youtube,但它会永远挂起调用 AuthorizeAsync。您还可以在以下位置查看代码:https://developers
GoogleWebAuthorizationBroker.AuthorizeAsync() 在(农场,4.5 NET)暂存服务器上失败,但在本地服务器上运行良好。我已按照帮助热线上的每个代码进行操作,
我们的网站需要从后台代码(asp.net mvc 应用程序)上传视频到youtube。我正在尝试获取 google 凭据,但是当我调用 AuthorizeAsync 时,应用程序只是挂起。我到处寻找解
我有一个 C# .net Web 应用程序,用于将视频上传到 Youtube。这在大约 6 个月前有效,但现在已停止工作。当我在本地计算机上通过 Visual Studio 启动网站时,以下代码挂起:
我正在编写一个 C# 桌面应用程序,可以将其输出复制到用户的 Google 云端硬盘。但是,当我尝试使用 GoogleWebAuthorizationBroker.AuthorizeAsync() 授
我正在尝试使用 Google Calendar API在我的非 MVC .NET Web 应用程序中。 (这似乎是一个重要的区别。) 我尝试使用来自 this example 的代码在谷歌和 this
我有一个使用 adsense api 的报告应用程序。 我正在使用 GoogleWebAuthorizationBroker.AuthorizeAsync 进行身份验证。 当我在本地使用它时,它工作正
我在将我的代码发布到 IIS7.0 后遇到 GoogleWebAuthorizationBroker.AuthorizeAsync 超时问题。 通过我的开发环境,一切都按预期工作。我看到了 Googl
我无法尝试从 MVC 应用程序访问特定的 Google 云端硬盘帐户。我所需要的只是让 MVC 网络应用程序访问我的谷歌驱动器扫描一些文件并根据谷歌驱动器的内容更改数据库。问题是在 IIS 中运行时,
我正在尝试使用 Azure 托管 Web 应用程序执行 OAuth2,但我无法使用服务帐户(此处有许多可用的解决方案,但它们都坚持服务帐户/证书),而我需要用户由 Google 进行身份验证和授权。
我正在尝试使用 Azure 托管 Web 应用程序执行 OAuth2,但我无法使用服务帐户(此处有许多可用的解决方案,但它们都坚持服务帐户/证书),而我需要用户由 Google 进行身份验证和授权。
服务器设置: ASP.NET 表单在 .net 4.5.1 集成管道上运行,在服务器 2012 上的 iis8 上运行。 我正在尝试从谷歌的 GoogleWebAuthorizationBroker
我想将 login_hint 附加到对 Google 的身份验证请求中。我正在使用以下代码: FileDataStore fDS = new FileDataStore(Logger.Folder,
当在 Windows 10 桌面/移动设备上运行时,此代码在我的 UWP 应用程序中运行良好,但在 Xbox One 上我收到错误: 我的 C# 代码: credential = await Goog
我在尝试让 MVC5 应用程序在部署时与 Google Mirror API(或与此相关的任何 Google API)一起工作时遇到了一个奇怪的问题。 这是我努力工作的代码: UserCredenti
我正在使用 GoogleWebAuthorizationBroker.AuthorizeAsync() 为 GoogleDrive 授权用户。 它适用于控制台或 UI 应用程序,但如果该方法在 Win
环境:.net 4.5.1 集成管道上的 ASP.NET 简单 Web 应用程序在服务器 2012 上的 iis8 上运行,不遵循 MVC。 我正在尝试从谷歌的 GoogleWebAuthorizat
我正在将 Google token 转换为 json 字符串格式并将该字符串存储在数据库中。 现在在谷歌驱动器中上传文件时,我想在 GoogleWebAuthorizationBroker.Autho
我遇到了与这个问题完全相同的问题: How do I set return_uri for GoogleWebAuthorizationBroker.AuthorizeAsync? 但是,这个问题在
我是一名优秀的程序员,十分优秀!