- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我有一个 C# .net Web 应用程序,用于将视频上传到 Youtube。这在大约 6 个月前有效,但现在已停止工作。当我在本地计算机上通过 Visual Studio 启动网站时,以下代码挂起:
UserCredential credential;
using (var auth_stream = new FileStream(Server.MapPath("~/YouTube/client_secrets.json"), FileMode.Open, FileAccess.Read))
{
credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.Load(auth_stream).Secrets,
// This OAuth 2.0 access scope allows an application to upload files to the
// authenticated user's YouTube channel, but doesn't allow other types of access.
new[] { YouTubeService.Scope.YoutubeUpload },
"user",
CancellationToken.None
);
}
在查看有关堆栈溢出的其他帖子后,我还尝试了以下操作:
UserCredential credentialS;
using (var auth_stream = new FileStream(Server.MapPath("~/YouTube/client_secrets.json"), FileMode.Open, FileAccess.Read))
{
credentialS = await GoogleWebAuthorizationBroker.AuthorizeAsync(
new ClientSecrets
{
ClientId = "blahblah-myDetailsBlahBLah.apps.googleusercontent.com",
ClientSecret = "myClientSecret",
},
// This OAuth 2.0 access scope allows an application to upload files to the
// authenticated user's YouTube channel, but doesn't allow other types of access.
new[] { YouTubeService.Scope.YoutubeUpload },
"user",
CancellationToken.None
);
}
我还注意到我使用的是 Google API 的 1.7.0-beta 版,因此我通过 PackageManager 控制台升级到了 1.8.2 版。
我还通过 Google Developer Console 生成了一个新的 Client Secret,并在我的网站中使用了它。
但在尝试这些步骤后,对 GoogleWebAuthorizationBroker.AuthorizeAsync 的调用仍然挂起。我注意到我在本地浏览器中的网站会刷新,就好像它正在尝试连接一样,但调用永远不会成功。
我该如何解决这个问题??
最佳答案
我在使用 Google Calendar API 时也遇到过这个问题。
我的应用程序正在从各种在线资源中抓取通知并将其发布到共享的谷歌日历。
它在开发环境中运行良好,但当我将它部署到虚拟机时却没有,在该虚拟机中使用该虚拟机中的服务帐户,它每 15 分钟作为 Windows 计划任务运行一次。
我记得第一次设置它时,我必须在浏览器中完成授权步骤,但当它作为计划任务运行时并没有被触发。
我找不到让它通过浏览器提示再次授予访问权限的方法。
由于服务帐户 C:\Users\\Documents.credentials\calendar-dotnet-quickstart 文件夹创建得很好,我只是从同一文件夹复制了 Google.Apis.Auth.OAuth2.Responses.TokenResponse-user在我的开发环境中,它现在工作正常。
这可能不是最好或最终的解决方案,但它确实有效。
我怀疑如果我以该服务用户的身份登录计划任务并从命令提示符运行,我会通过浏览器收到授予授权的提示。
希望这对某人有帮助。
关于c# - GoogleWebAuthorizationBroker.AuthorizeAsync 卡住,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32169124/
我尝试使用 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() 授
问题已更新,以便更好地解释我遇到的问题, 只要我有这个 Controller , [Authorize] public class IdeaManagementController :
我正在尝试更改我们对 .net 客户端库的旧 rest 调用,我有两个相关的问题/问题...... 此页面上的示例应用程序 https://developers.google.com/api-clie
我正在尝试使用 Google Calendar API在我的非 MVC .NET Web 应用程序中。 (这似乎是一个重要的区别。) 我尝试使用来自 this example 的代码在谷歌和 this
我有一个使用 adsense api 的报告应用程序。 我正在使用 GoogleWebAuthorizationBroker.AuthorizeAsync 进行身份验证。 当我在本地使用它时,它工作正
我有一个我编写的 C# 库,它提供了一些辅助函数来访问 Google 云端硬盘。 服务构造函数调用 AuthorizeAsync 如下: // get access token var credent
我在将我的代码发布到 IIS7.0 后遇到 GoogleWebAuthorizationBroker.AuthorizeAsync 超时问题。 通过我的开发环境,一切都按预期工作。我看到了 Googl
我正在尝试使用 Azure 托管 Web 应用程序执行 OAuth2,但我无法使用服务帐户(此处有许多可用的解决方案,但它们都坚持服务帐户/证书),而我需要用户由 Google 进行身份验证和授权。
我正在尝试使用 Azure 托管 Web 应用程序执行 OAuth2,但我无法使用服务帐户(此处有许多可用的解决方案,但它们都坚持服务帐户/证书),而我需要用户由 Google 进行身份验证和授权。
服务器设置: ASP.NET 表单在 .net 4.5.1 集成管道上运行,在服务器 2012 上的 iis8 上运行。 我正在尝试从谷歌的 GoogleWebAuthorizationBroker
当在 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
我是一名优秀的程序员,十分优秀!