YouTube Api with ASP.NET 4.5 WebForms - OAuth2 iss

2019-06-09 19:55发布

i beg for your help with this...

We need to upload videos to Youtube Channel, with a WebForms application. So, this is the main lines of the code i d like to show you:

        var folder = System.Web.HttpContext.Current.Server.MapPath("~/App_Data/GoogleData");
        UserCredential credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
        new ClientSecrets
        {
            ClientId = ConfigInfo.YouTubeApiClient_id,
            ClientSecret = ConfigInfo.YouTubeAppClient_secret,
        },
         new[] { YouTubeService.Scope.YoutubeUpload },
         "user",
         CancellationToken.None,
        new FileDataStore(folder,true)).Result;

The error i have is: System.ComponentModel.Win32Exception: Access is denied.

Some additional information if it s helpfull:

  • I've created the clientId and the credential in console.developers.google.com as an Application.
  • It works fine on my localhost if i debug the application, but it does not work on the Arvixe shared hosting server.

This is what i ve already tried:

  • The first thing came to my mind was giving Read/Write Permissions on that folder (GoogleData), so i done that but still same error.
  • I ve also asked Arvixe support team to give Everyone-Full Control access to that folder (they say they ve already done that, but not sure)
  • I ve also tried to remove the FileDataSource parameter and use GoogleWebAuthorizationBroker.Folder, but same error.
  • I ve read all the Google Examples, and codes, but all of them are for console or desktop application, and i have a web application with a web server.

Please, any help you can give us will be really appreciated ! Thanks again !

1条回答
男人必须洒脱
2楼-- · 2019-06-09 20:30

I recently had a very similar issue to yours, and also hosted on Arvixe. I fixed it by changing the .NET target framework version from 4.5.2 to 4.5.

I wrote a short article about it that has some more info, and more solutions to try. I hope this helps!

查看更多
登录 后发表回答