I'm running a process without UI that retrieves uploaded videos from youtube. On a develpement machine it authenticates on user behalf and it works.

The problem is when process is running on a server: browser window doesn't fire for user to let use his account (it should only require to do it once). 

Event viewer shows no errors whatsoever. Service accounts doesn't seem to work with youtube, with API key is too less permissions and
oath is the only way to authenticate and get broadcasted videos. Or am I wrong? 

So the question is: How to run a service as a single user and retrieve his videos without UI?

```
         private async Task Run()
                {

                    try
                    {
                        UserCredential credential;
                        using (var stream = new FileStream(StartPath + "\\client_secrets.json", FileMode.Open, FileAccess.Read))
                        {

                            credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(
                                GoogleClientSecrets.Load(stream).Secrets,
                                new[] { YouTubeService.Scope.YoutubeReadonly, YouTubeService.Scope.Youtube  },
                                "user",
                                CancellationToken.None,
                                new FileDataStore("Store")
                            );
                        }

                        var youtubeService = new YouTubeService(new BaseClientService.Initializer()
                        {
                            HttpClientInitializer = credential,
                            ApplicationName = this.GetType().ToString()
                        });
    ....
                 }

```

I have also tried:

```
 String serviceAccountEmail = "e-mail";

            var certificate = new X509Certificate2(HostingEnvironment.MapPath("~/Content/key.p12"), "notasecret", X509KeyStorageFlags.Exportable);

            ServiceAccountCredential credential = new ServiceAccountCredential(
               new ServiceAccountCredential.Initializer(serviceAccountEmail)
              {
                   Scopes = new[] { YouTubeService.Scope.Youtube, YouTubeService.Scope.YoutubepartnerChannelAudit, YouTubeService.Scope.YoutubeUpload }
               }.FromCertificate(certificate));
            var youtubeService = new YouTubeService(new BaseClientService.Initializer()
            {
                HttpClientInitializer = credential,
                ApplicationName = "api",
            });

```