我已经实现了访问YouTube和Analytics API的实现,这在localhost上工作正常,但是当我在预生产中尝试时,请求只是超时并且验证的同意窗口甚至都没有显示出来。
这是我的YouTube身份验证码:
string[] scopes = new string[] { YouTubeService.Scope.Youtube, // view and manage your YouTube account
YouTubeService.Scope.YoutubeForceSsl,
YouTubeService.Scope.Youtubepartner,
YouTubeService.Scope.YoutubepartnerChannelAudit,
YouTubeService.Scope.YoutubeReadonly,
YouTubeService.Scope.YoutubeUpload};
try
{
// here is where we Request the user to give us access, or use the Refresh Token that was previously stored in %AppData%
UserCredential credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
new ClientSecrets { ClientId = clientId, ClientSecret = clientSecret }
, scopes
, userName
, CancellationToken.None
, new DatabaseDataStore("Youtube")).Result;
YouTubeService service = new YouTubeService(new YouTubeService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "Masterpiece",
});
return service;
}
catch (Exception ex)
{
Console.WriteLine(ex.InnerException);
return null;
}
我基本上有一个" Connect"页面上的按钮,当我点击它时,页面应该进行回发并在服务器端对Google API进行身份验证。但在预生产中,回发只会挂起,最终我收到此错误消息: