使用Google.Api OAuth 2时,拒绝访问路径';C:Windowssystem32configsystemprofile'; [英] Access to the path 'C:Windowssystem32configsystemprofile' is denied when using Google.Api OAuth 2
本文介绍了使用Google.Api OAuth 2时,拒绝访问路径';C:Windowssystem32configsystemprofile';的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在对我的一个项目使用Google Calendar Api
。我不知道是怎么回事,但下面显示的错误令人担忧。
内部代码AppFlowMetadata
。
public class AppFlowMetadata : FlowMetadata
{
private static readonly IAuthorizationCodeFlow flow =
new GoogleAuthorizationCodeFlow(new GoogleAuthorizationCodeFlow.Initializer
{
ClientSecrets = new ClientSecrets
{
ClientId = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com",
ClientSecret = "xxxxx_xxxxxxxxxxxxxxxxx"
},
Scopes = new[] { CalendarService.Scope.Calendar },
DataStore = new FileDataStore("Calendar.Api.Auth.Store")
});
public override string GetUserId(Controller controller)
{
var user = controller.Session["UserID"];
if (user == null)
{
user = Guid.NewGuid();
controller.Session["UserID"] = user;
}
return user.ToString();
}
public override IAuthorizationCodeFlow Flow
{
get { return flow; }
}
}
我尝试了GitHub的以下解决方案,但不起作用
以上解决方案对我不起作用,如果有任何解决方案,请帮助我。
推荐答案
根据https://domantasjovaisas.wordpress.com/2014/09/27/demystifying-google-api-and-oauth2/:
从我刚才提供的代码中,您可以看到我正在使用File2DataStore。 它被我覆盖了。标准文件DataStore我更改为我自己的 需要。Standard FileDataStore将身份验证密钥存储在 "C:WINDOWSsystem32configsystemprofileAppDataRoamingDrive.Api.Auth.Store"
我认为您不会允许IIS_IUSRS用户访问此 在生产环境中的位置🙂三思而后行,不要这么做。 根据您自己的需要重写FileDataSource。这里有两个例子,说明您如何 可以做到:
https://code.google.com/p/google-api-dotnet-client/source/browse/Src/GoogleApis.DotNet4/Apis/Util/Store/FileDataStore.cs http://www.daimto.com/google-oauth2-csharp/#FileDataStore
简而言之,您需要停止使用FileDataStore
并编写您自己的替代品(使用以上链接作为起点)。
这篇关于使用Google.Api OAuth 2时,拒绝访问路径';C:Windowssystem32configsystemprofile';的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文