gpt4 book ai didi

c# - GoogleWebAuthorizationBroker.AuthorizeAsync 登台服务器失败

转载 作者:太空宇宙 更新时间:2023-11-03 12:49:46 30 4
gpt4 key购买 nike

GoogleWebAuthorizationBroker.AuthorizeAsync() 在(农场,4.5 NET)暂存服务器上失败,但在本地服务器上运行良好。我已按照帮助热线上的每个代码进行操作,但仍然无济于事。

这是我的代码:

String gpath = Server.MapPath("credentials/siteAPI.json");
UserCredential credential;

string credPath = Server.MapPath("credentials");

using (var stream = new FileStream(gpath, FileMode.Open, FileAccess.Read))
{
credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.Load(stream).Secrets,
new[] { CalendarService.Scope.Calendar },//
"xx@ccc.com",
CancellationToken.None,
new AppDataFileStore(credPath)
).Result;
}

我得到这个错误:

System.AggregateException: One or more errors occurred.
---> System.ComponentModel.Win32Exception: Access is denied
at Microsoft.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at Microsoft.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccess(Task task)
at Google.Apis.Auth.OAuth2.GoogleWebAuthorizationBroker.d__1.MoveNext() in C:\Users\mdril\Documents\GitHub\google-api-dotnet-client\Src\GoogleApis.Auth.DotNet4\OAuth2\GoogleWebAuthorizationBroker.cs:line 59
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
at System.Threading.Tasks.Task`1.get_Result()
at z2.Page_Load(Object sender, EventArgs e) in e:\hostingspaces\cal1234\mysitecalendar.com\wwwroot\z2.aspx.cs:line 169
---> (Inner Exception #0) System.ComponentModel.Win32Exception (0x80004005): Access is denied
at Microsoft.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at Microsoft.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccess(Task task)
at Google.Apis.Auth.OAuth2.GoogleWebAuthorizationBroker.d__1.MoveNext() in C:\Users\mdril\Documents\GitHub\google-api-dotnet-client\Src\GoogleApis.Auth.DotNet4\OAuth2\GoogleWebAuthorizationBroker.cs:line 59<---

根据我读到的其他说明,这是由于服务器端的权限问题,但是对于一个养殖站点,我无法再控制任何权限。

有趣的是,当我将一个已批准的凭据从我的本地服务器复制到登台服务器时,一切正常!暂存服务器似乎无法(或没有权限)启动屏幕以请求用户批准 token !

我该如何解决?

最佳答案

我在同一个问题上花了几个小时,终于找到了一篇帮助我解决问题的帖子。帖子在这里http://answers.flyppdevportal.com/MVC/Post/Thread/7819b19d-07d0-4584-a061-cace0688bfb2?category=sharepointdevelopment

在我使用此代码的开发服务器上,在 credPath(请参阅上面代码中的此变量)文件夹中创建了一个 token 响应文件。

我只是将此文件复制到暂存服务器,但它对我不起作用。这为我解决了这个问题..

这可能是因为页面向用户显示了同意网页(在开发服务器中工作)并且在无法显示页面的情况下导致此错误。同样,这都是理论,但上述解决方案对我有用。

关于c# - GoogleWebAuthorizationBroker.AuthorizeAsync 登台服务器失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36017661/

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