Why do I get System.UnauthorizedAccessException Access to the path 'Google.Apis.Auth' is denied

后端 未结 3 2051
误落风尘
误落风尘 2020-12-07 02:37

I have implemented google drive functionality for file management its working fine in local system but whenever i hosted it on Godaddy server it throw following error

<
相关标签:
3条回答
  • 2020-12-07 02:52

    Root cause of the problem : This issue is generated because after validating authentication request its create directory and token file under in window's user's folder and we have not right's for that folder of Godadday server so it was not working

    Solution : Modified the source code of google apis[filedatasource.cs] for creating that file inside our directory and add reference of it and it will work

    0 讨论(0)
  • 2020-12-07 02:53

    I think you will find a solution here: Deploying ASP.NET to Windows Azure cloud, application gives error when running on cloud.

    You just need to configure your IIS to work with the FileDataStore.

    The following is copied from the answer there:

    A.If you have RDP Acces to the Azure cloud then change the IIS settings

    1.Go to the IIS
    2.Under sites select the Default site
    3.Add Permission
    4.choose I_User object and give read/write access.
    5.later you can automate this setting using a batch file and startup task.
    

    B.I think you are using any local path. You should change this to local storage for temporary requirement and blob storage for long requirement.

    0 讨论(0)
  • 2020-12-07 02:56

    Expanding what Chandrika has already said, the ASP.NET user needs read and write permissions to the Google API Client OAuth2 Library's permanent storage folder .

    Its default value is a folder named "Google.Apis.Auth" in Environment.SpecialFolder.ApplicationData (which usually corresponds to C:\Users\your-user-name\AppData\Roaming).

    Alternatively, another folder can be provided as the last parameter of the GoogleWebAuthorizationBroker.AuthorizeAsync() method:

    var folder = System.Web.HttpContext.Current.Server.MapPath("/App_Data/MyGoogleStorage");
    
    UserCredential credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
       new ClientSecrets
       {
           ClientId = "PutYourClientIdHere",
           ClientSecret = "PutYourClientSecretHere"
       },
       new[] { DriveService.Scope.Drive },
       "user",
       CancellationToken.None,
       new FileDataStore(folder)).Result;
    
    return credential;
    

    See: https://developers.google.com/api-client-library/dotnet/guide/aaa_oauth#credentials and https://developers.google.com/accounts/docs/OAuth2

    0 讨论(0)
提交回复
热议问题