I have a C# .net web application that I use to upload videos to Youtube. This worked about 6 months ago but now it has stopped working. The following code just hangs when I launch my website via Visual Studio on my local computer:
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
);
}
I have also tried the following after looking at other posts on stack overflow:
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
);
}
I also notived that I was using version 1.7.0-beta of the Google APIs so I upgraded via PackageManager console to version 1.8.2.
I also generated a new Client Secret via the Google Developer Console and used that in my website.
But after trying these steps the call to GoogleWebAuthorizationBroker.AuthorizeAsync still hangs. I notice that my website in my local browser refreshes as if its attempting to connect but the call is never seccessful.
How can I solve this??