System.UnauthorizedAccessException的访问路径'Google.Apis.Auth'被拒绝 [英] System.UnauthorizedAccessException Access to the path 'Google.Apis.Auth' is denied
问题描述
我已经实现谷歌驱动器功能进行文件管理及其工作在本地系统中运行良好,但每当我主持这Godaddy的服务器上扔了以下错误
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
System.UnauthorizedAccessException的
访问路径Google.Apis.Auth'被拒绝。
System.UnauthorizedAccessException Access to the path 'Google.Apis.Auth' is denied.
继code,我使用:
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;
我使用VS2010,以上功能IIS 7
I am using VS2010,IIS 7 for above functionality
推荐答案
拓展什么钱德里卡已经说过,ASP.NET用户需要读取和写入权限谷歌API客户端的OAuth2库的永久存储文件夹。
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 .
它的默认值是 Environment.SpecialFolder.ApplicationData code>名为Google.Apis.Auth的文件夹(通常是对应于
C:\\ Users \\您的用户名\\ AppData \\漫游
)。
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
).
此外,另一个文件夹,可以作为的<一的最后一个参数提供href=\"https://$c$c.google.com/p/google-api-dotnet-client/source/browse/Src/GoogleApis.Auth.DotNet4/OAuth2/GoogleWebAuthorizationBroker.cs\"相对=nofollow> GoogleWebAuthorizationBroker.AuthorizeAsync()
方式:
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;
请参阅:的https://developers.google.com/api-client-library/dotnet/guide/aaa_oauth#credentials和 https://developers.google.com/accounts/docs/OAuth2
这篇关于System.UnauthorizedAccessException的访问路径'Google.Apis.Auth'被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!