我们的网站需要从后面的代码(asp.net mvc 应用程序)上传视频到youtube.我正在尝试获取 google 凭据,但是当我调用 AuthorizeAsync 时,应用程序只是挂起.我四处寻找解决方案,但似乎没有任何帮助.我已经在谷歌和堆栈溢出上搜索过明显的.我发现的大部分内容都提到该应用程序可能无法访问 appdata 文件夹,因此我尝试将该文件夹更改为位于 c 驱动器、d 驱动器和实际 inetpub 位置中.我测试并发现我能够让应用程序写入这些位置.
Our website needs to upload videos to youtube from the code behind (asp.net mvc application). I'm trying to get the google credentials, but when i call the AuthorizeAsync, the application just hangs. I've looked all over for a solution and none seem to help out. I've already searched for the obvious on google and stack overflow. most of what i found mentioned that the application might not have access the the appdata folder, so i tried changing the folder to be in the c drive, d drive and in the actual inetpub location. i tested and found i was able to have the application write to those locations.
更具体地说,用户是我们的管理员,客户上传视频给我们,管理员批准.当管理员批准它们时,它会发布在我们的 youtube 帐户上.管理员无需执行任何操作,只需单击批准"按钮即可.
to be more specific, the user is our admin, customers upload videos to us, and the admin approves them. when the admin approves them, it is posted on our youtube account. the admin should not have to do anything but click the approve button.
为了使这成为一个实际问题,我该怎么做才能通过 AuthorizeAsync?如果您需要更多信息,请告诉我
To make this an actual question, what can i do to get past the AuthorizeAsync? Let me know if you need more info
UserCredential credential;
GoogleWebAuthorizationBroker.Folder = "YouTube.Auth.Store";
using (var stream = new FileStream(CredentialsPath, FileMode.Open,
FileAccess.Read))
{
credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.Load(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,
new FileDataStore("YouTube.Auth.Store")
).Result;
}
找到了解决这个问题的方法.
Found a way to get passed this.
我改用了 GoogleAuthorizationCodeFlow.结果是这样的:
I used GoogleAuthorizationCodeFlow instead. this is what it turned out to look like:
ClientSecrets secrets = new ClientSecrets()
{
ClientId = CLIENT_ID,
ClientSecret = CLIENT_SECRET
};
var token = new TokenResponse { RefreshToken = REFRESH_TOKEN };
var credentials = new UserCredential(new GoogleAuthorizationCodeFlow(
new GoogleAuthorizationCodeFlow.Initializer
{
ClientSecrets = secrets
}),
"user",
token);
var service = new YouTubeService(new BaseClientService.Initializer()
{
HttpClientInitializer = credentials,
ApplicationName = "TestProject"
});
这篇关于GoogleWebAuthorizationBroker.AuthorizeAsync 挂起的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!