简体   繁体   English

为什么我得到System.UnauthorizedAccessException拒绝访问路径'Google.Apis.Auth'被拒绝

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

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 我已经为文件管理实现了谷歌驱动器功能,它在本地系统中运行良好,但每当我在Godaddy服务器上托管它时,它会抛出以下错误

System.UnauthorizedAccessException Access to the path 'Google.Apis.Auth' is denied. System.UnauthorizedAccessException拒绝访问路径“Google.Apis.Auth”。

Following code i am using : 以下代码我正在使用:

UserCredential credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
   new ClientSecrets
   {
       ClientId = System.Configuration.ConfigurationManager.AppSettings["GDriveClientId"],//Get ClientID from web.config.
       ClientSecret = System.Configuration.ConfigurationManager.AppSettings["GDriveClientSecret"]//Get ClientSecret from web.config.
   },
   new[] { DriveService.Scope.Drive },
   System.Configuration.ConfigurationManager.AppSettings["GDriveCreatedByUser"],//Get UserName from web.config.
   CancellationToken.None).Result;

return credential;

I am using VS2010,IIS 7 for above functionality 我正在使用VS2010,IIS 7来实现上述功能

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 . 扩展Chandrika已经说过的内容,ASP.NET用户需要对Google API客户端OAuth2库的永久存储文件夹具有读写权限。

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 ). 其默认值是Environment.SpecialFolder.ApplicationData名为“Google.Apis.Auth”的文件夹(通常对应于C:\\Users\\your-user-name\\AppData\\Roaming )。

Alternatively, another folder can be provided as the last parameter of the GoogleWebAuthorizationBroker.AuthorizeAsync() method: 或者,可以提供另一个文件夹作为GoogleWebAuthorizationBroker.AuthorizeAsync()方法的最后一个参数:

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 请参阅: https//developers.google.com/api-client-library/dotnet/guide/aaa_oauth#credentialshttps://developers.google.com/accounts/docs/OAuth2

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 问题的根本原因:生成此问题是因为在验证身份验证后请求其创建目录和令牌文件位于窗口的用户文件夹下,并且我们没有权利使用Godadday服务器的该文件夹,因此无法正常工作

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 解决方案:修改了谷歌apis [ filedatasource.cs ]的源代码,用于在我们的目录中创建该文件,并添加它的引用,它将工作

I think you will find a solution here: Deploying ASP.NET to Windows Azure cloud, application gives error when running on cloud . 我认为你会在这里找到一个解决方案:将ASP.NET部署到Windows Azure云,应用程序在云上运行时会出错

You just need to configure your IIS to work with the FileDataStore. 您只需配置IIS即可使用FileDataStore。

The following is copied from the answer there: 从那里的答案中复制以下内容:

A.If you have RDP Acces to the Azure cloud then change the IIS settings 答:如果您有到Azure云的RDP访问权限,则更改IIS设置

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.

BI think you are using any local path. BI认为您正在使用任何本地路径。 You should change this to local storage for temporary requirement and blob storage for long requirement. 您应该将此更改为本地存储以用于临时要求和blob存储以满足长期要求。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 拒绝访问Google.Apis.Auth路径 - Access to the path Google.Apis.Auth is denied mvc c#拒绝访问路径“ Google.Apis.Auth” - Access to the path 'Google.Apis.Auth' is denied mvc c# System.UnauthorizedAccessException:访问路径:拒绝PATH - System.UnauthorizedAccessException: Access to the path:PATH is denied UWP System.UnauthorizedAccessException:拒绝访问路径 - UWP System.UnauthorizedAccessException: Access to the path is denied System.UnauthorizedAccessException:拒绝访问路径“...” - System.UnauthorizedAccessException: Access to the path "..." is denied DotNetZip System.UnauthorizedAccessException:拒绝访问路径 - DotNetZip System.UnauthorizedAccessException: Access to the path is denied System.UnauthorizedAccessException:拒绝访问路径“...” - System.UnauthorizedAccessException: Access to the path '...' is denied System.UnauthorizedAccessException拒绝访问路径 - System.UnauthorizedAccessException Access to the path is denied System.UnauthorizedAccessException:访问路径被拒绝 - System.UnauthorizedAccessException: Access to the path denied System.UnauthorizedAccessException:访问路径拒绝错误 - System.UnauthorizedAccessException: Access to the path denied error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM