我正在使用以下代码创建与Google Drive API的连接:
using (var stream = new FileStream("client_secret.json", FileMode.Open, FileAccess.ReadWrite))
{
string credPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
credPath = Path.Combine(credPath, ".credentials/drive-dotnet-quickstart.json");
try
{
this.credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.Load(stream).Secrets,
Scopes,
"Google Drive Import",
CancellationToken.None,
new FileDataStore(credPath, true)).Result;
}
catch(Exception ex)
{
log.Error("Exception caught in creating Drive connection" + ex.InnerException.Message);
}
}
这似乎可以用于从我的PC创建连接(使用VS 2015在Win10中编译/执行),但是当我尝试从服务器(使用VS 2015在Windows Server 2012 R2中编译/执行)时,我得到了“访问权限”在调试时拒绝了。我在这里做错了什么?
到目前为止,我已经在两台PC上比较了Fiddler的日志,我看到了来自两个工作站的所有200个结果代码。
答案 0 :(得分:0)
@DaImTo帮我解决了这个问题。将文件写入credPath位置的权限是一个问题。在评论中,您将找到一个帮助更改为自定义数据存储的链接:daimto.com/google-net-filedatastore-demystified。再次感谢@DaImTo。