0
votes

I have been trying to upload a video to YouTube from my website for the past two days. The is no documentation for VB nor is there much working examples for .Net.

I am looking for anyway to upload videos to youtube by any means possible. I have tried YouTube Data API 3 and YouTube Data API 2 with no success.

Following the YouTube api i am trying to get my UserCredentials https://developers.google.com/youtube/v3/code_samples/dotnet#upload_a_video

I have created a OAuth key and a public api key on the google console. https://console.developers.google.com/project

UserCredential credential;
using (var stream = new FileStream("client_secrets.json", FileMode.Open, FileAccess.Read))
{
  credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(
  GoogleClientSecrets.Load(stream).Secrets,
  // This OAuth 2.0 access scope allows for full read/write access to the
  // authenticated user's account.
  new[] { YouTubeService.Scope.Youtube },
  "user",
  CancellationToken.None,
  new FileDataStore(this.GetType().ToString())
);
}

If anyone has gotten this above section working or knows a place where i can see how to get it working that would be much appreciated.

My attempt at YouTube Data API 3 I have to use VB but will accept answers in C# as i can convert it, any working UserCredentials examples will be an accepted answer.

First of two problems is i need this in VB. I have a blue line under () by the new.

Using stream = New FileStream("client_secrets.json", FileMode.Open, FileAccess.Read)
    credential = GoogleWebAuthorizationBroker.AuthorizeAsync(GoogleClientSecrets.Load(stream).Secrets, New () {YouTubeService.Scope.YoutubeReadonly}, "user", CancellationToken.None, New FileDataStore(Me.[GetType]().ToString()))
End Using

Second problem is i have no idea what should go into "client_secrets.json"

My attempt at YouTube Data API 2: Upload video to YouTube, Execution of request failed, (401) Unauthorized

1
I Think i have got the client_secrets.json.Pomster

1 Answers

0
votes

client_secrets.json is in this format

{
  "installed": {
    "client_id": “REPLACE_ME”,
    "client_secret": “REPLACE_ME"
  }
}

You get those values from Google Developer Console.

You can find .Net examples here: https://github.com/youtube/api-samples/tree/master/dotnet