【发布时间】:2015-06-18 06:15:34
【问题描述】:
我使用 Youtube Data Api(v3) 从 Youtube 帐户获取数据。 我使用此链接 https://console.developers.google.com/ 为 Web 应用程序创建 ClientId 和 ClientSecret。
当我在本地运行我的项目时,一切正常。当我尝试在服务器中托管项目时,它给出了一个异常,上面写着
访问路径 ASP.****.aspx 页面被拒绝
在调试解决方案时,我注意到这部分代码导致了异常:
UserCredential credential;
credential = await GoogleWebAuthorizationBroker.AuthorizeAsync (
new ClientSecrets
{
ClientId = ClientId,
ClientSecret = ClientSecret
},
new[] { YouTubeService.Scope.YoutubeReadonly },
"user",
CancellationToken.None,
new FileDataStore(GetType().ToString())
);
【问题讨论】:
-
FileDatastore 将文件存储在 %appdata% 中,确保它可以访问该文件。确保您将 Google 开发人员控制台中的重定向 uri 更改为服务器,而不是您的 localhost 机器。检查防火墙,确保你没有因为某种原因阻止谷歌服务器。
-
感谢您的回复DalmTo..我做了你上面提到的事情..但这一次..页面继续加载..它甚至没有返回任何异常或输出..
标签: youtube-api