1

I am using the code below to upload a video to YouTube. It works with one of my YouTube accounts but with the other one it does not work. I just replace the Client Id and Client Secret to switch between YouTube accounts. Any ideas on why it does not work with my other YouTube account?

var provider = new NativeApplicationClient(GoogleAuthenticationServer.Description)
                {
                    ClientIdentifier = ClientId,
                    ClientSecret = ClientSecret
                };
                var auth = new OAuth2Authenticator<NativeApplicationClient>(provider, GetAuthorization);

                var youtube = new YouTubeService(new BaseClientService.Initializer()
                {
                    Authenticator = auth
                });

                var video = new Video();
                video.Snippet = new VideoSnippet();
                video.Snippet.Title = "Demo 1"; 
                video.Snippet.Description = "Demo 1a"; 
                video.Snippet.Tags = new string[] { "tag1", "tag2" };
                video.Snippet.CategoryId = "22"; 
                video.Status = new VideoStatus();
                video.Status.PrivacyStatus = "private"; 
                var filePath = @"C:\wildlife.wmv"; 
                var fileStream = new FileStream(filePath, FileMode.Open);

                var videosInsertRequest = youtube.Videos.Insert(video, "snippet,status", fileStream, "video/*");
                videosInsertRequest.ProgressChanged += videosInsertRequest_ProgressChanged;
                videosInsertRequest.ResponseReceived += videosInsertRequest_ResponseReceived;

                var uploadThread = new Thread(() => videosInsertRequest.Upload());
                uploadThread.Start();
                uploadThread.Join();
2
  • Have you turned on youtube service in the other one? Commented Sep 18, 2013 at 13:33
  • yes I did. I checked. Commented Sep 18, 2013 at 18:34

1 Answer 1

1

You don't need to change client id and secret to upload into different accounts. Client id and secret define the developer, for the channel that the upload will happen, you only need to authorize with that login.

Sign up to request clarification or add additional context in comments.

2 Comments

What login? How does the code know what account to upload to?
There are two ways to access the API: 1) As a standalone developer, simply providing a ClientID and a ClientSecret or 2) As a registered user on your app, that completed the OAuth2 login flow ( accepted permissions, got redirected.. and so forth). Currently you are using method 1) and from what I understood for your requirements you need method 2).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.