[英]Access to the path is denied. google api local iis publish
当我必须为Google用户验证身份验证时,无法访问某些文件夹。
我收到错误消息:在IIS上本地发布时, Access to the path '..' is denied
。
我试图更改文件夹位置,因此它将位于项目的App_Data中-祝您好运。
我也曾尝试做这些家伙在做什么,但也没有帮助。
我的代码如下:
string path = AppDomain.CurrentDomain.BaseDirectory + @"\Json\client_secrets.json";
using (var stream = new FileStream(path, FileMode.Open, FileAccess.Read))
{
try
{
string googlecalendarpath = folderpath + @"\App_Data\GoogleCalendar";
credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.Load(stream).Secrets, scopes,
_currentAccountNo,
//Vær sikker på, at dette er det samme altid, og er unikt, da ens permissions til Google Calendar bliver bundet op på dette!
CancellationToken.None, new FileDataStore(googlecalendarpath)).Result;
}
catch (Exception ex)
{
return "Cred. FEJL: " +ex.GetFullExceptionString();
}
}
,其中folderpath
来自Server.MapPath("~/App_Data")
,并且_currentAccountNo
是唯一的。 我在网上查看示例时看不到我缺少的内容,也看不到我做错了什么。
尝试以管理模式运行Visual Studio。
FileDatastore默认将文件放入%appData%中。 通常我会做类似的事情。 (假设我也使用“ _currentAccountNo”)
new FileDataStore("Console.Analytics.Auth.Store")
然后当我调用它时,我得到一个名为
%AppData%\Roaming\Console.Analytics.Auth.Store
该目录中现在存在一个名为
Google.Apis.Auth.OAuth2.Responses.TokenResponse-[account Num]
将目录发送到fileDataStore只会创建一个目录,其中包含您发送到fileDataStore的目录的名称,格式为%appdata%,这可能不是您想要的。
您可能想研究使用LocalFileDataStore,或者更好地创建自己的idatastore实现。
我不确定这是否是您的问题。 如果IIS可以访问%appdata%目录,则如何设置IIS是很棘手的。 这取决于您将其设置为哪个用户以及其运行方式为哪个应用程序池。 例如,如果内存服务Azure只能访问temp目录。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.