-2

I am new from youtube api. I would like to have a console program schedule upload videos to youtube without authorization everytime.

I see many posts and videos but not the complete story, I download the sample from Github and try to run it. It failed.

i follow the guide that

。create OAuth client ID and application type choose Other

。download code from github

。click allow in browser, lets youtube api manage youtube account.

enter image description here

img1 - client secret download from console developer and code from github

img2 - error message told me unauthorized enter image description here

which part is wrong, how can i fix it? Please help!

Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449
lei
  • 1
  • 1

1 Answers1

0

The error your getting means that you have not authenticated the YouTubeService there must be something wrong with your credentials which i cant see because you haven't posted all your code.

The YouTube API does not support service accounts. You will need to authenticate your code at least once. This is done via a web browser and the client library you are using will store the credentials for "user" in %appData% directory.

The tutorial you are following doesn't say anything about not needing authentication. This is the code for the auth.

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())
        );
      }
Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449
  • the sample program also include the partial code you provide. I am new so i only can post two links in the post. – lei Jul 03 '17 at 09:11
  • @Dalm, exactly the same with yours, but error is unauthorized. Is the network, proxy, firewall affect? – lei Jul 03 '17 at 09:18