gpt4 book ai didi

.net - 使用 Google.Api OAuth 2 时拒绝访问路径 'C:\Windows\system32\config\systemprofile'

转载 作者:行者123 更新时间:2023-12-04 00:25:00 25 4
gpt4 key购买 nike

我正在使用 Google Calendar Api与我的项目之一。我不知道如何,但下面显示的错误令人不安。

Here is the Error

Stack Trace of Error

里面的代码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 上尝试了以下解决方案,但没有用

I tried this Solution

以上解决方案对我不起作用,如果有答案请帮助。

最佳答案

根据 https://domantasjovaisas.wordpress.com/2014/09/27/demystifying-google-api-and-oauth2/ :

From code I just provided you can see that I’m using File2DataStore. It’s overridden by me. Standard FileDataStore I changed to my own needs. Standard FileDataStore stores auth keys in “C:\WINDOWS\system32\config\systemprofile\AppData\Roaming\Drive.Api.Auth.Store”

I don’t think so that you will allow IIS_IUSRS users access this location in production environment 🙂 Think twice, don’t do that. Rewrite FileDataSource to your own needs. Here is two examples how you can do it :



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并编写自己的替代品(使用上述链接作为起点)。

关于.net - 使用 Google.Api OAuth 2 时拒绝访问路径 'C:\Windows\system32\config\systemprofile',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45103628/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com