使用GoogleWebAuthorizationBroker上传到youtube频道,访问是天蓝色的拒绝异常错误,在本地工作正常

时间:2017-04-16 20:39:09

标签: c# asp.net-mvc youtube-api

我正在使用应用程序通过Azure App服务将视频上传到youtube。我正在使用此代码来验证用户

   UserCredential credential;
    ClientSecrets secret = new ClientSecrets
    {
        ClientId = "Client_id",
        ClientSecret = "Client_secret"
    };
        //Folder Path
        var folder = System.Web.HttpContext.Current.Server.MapPath("~/Content/Videos/");
        //Authenticate the user
        credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
                secret,
                new[] { YouTubeService.Scope.YoutubeUpload },
               Environment.UserName,
                CancellationToken.None,
                 new FileDataStore(folder + "folder")
            ).Result;

        // Initialize youtube service against authenticated user 

        var youtubeService = new YouTubeService(new BaseClientService.Initializer()
        {
            HttpClientInitializer = credential,
            ApplicationName = Assembly.GetExecutingAssembly().GetName().Name
        });

这工作正常,当我在本地系统上测试时上传视频但是当我将网站发布到azure时,会发出异常“发生一个或多个错误”。内部异常说“访问被拒绝”,堆栈跟踪是

     at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
   at System.Threading.Tasks.Task`1.get_Result()

我对路径有写权限,因为我正在那里存储视频。几乎2天玩Filedatastore等但没有成功。 请帮忙

0 个答案:

没有答案