【发布时间】:2015-06-11 11:15:07
【问题描述】:
我在使用 gmail api for c# 对我的应用程序进行身份验证时遇到问题。如果有人可以提供帮助,我将不胜感激! myCredintial 和 myServer 是定义服务器类的私有类,每次我在调用 AuthorizeBroker 时收到“System.IO.FileNotFoundException 错误”
if (myServer != null)
return;
Uri secrets = new Uri("ms-appx:///Assets/client_secrets.json");
myCredential = await GoogleWebAuthorizationBroker.AuthorizeAsync(new Uri("ms-appx:///Assets/client_secrets.json", UriKind.RelativeOrAbsolute),
new[] { GmailService.Scope.GmailReadonly },
"user",
CancellationToken.None);
String s = myCredential.UserId;
myServer = new GmailService(new BaseClientService.Initializer()
{
HttpClientInitializer = myCredential,
ApplicationName = "test",
});
【问题讨论】:
-
您是否收到任何错误响应或错误代码?
-
实际上它给了我一个找不到文件的异常,这真的很奇怪,因为当我在预期文件旁边传递另一个 json 文件的 uri 时,它给了我另一个格式不匹配或其他错误!有什么想法???
-
我想我有点晚了,但最好的猜测是检查文件
Copy to output directory设置是否设置为Copy always或Copy if newer。可以在解决方案资源管理器的文件属性中设置。 -
我忘记更新帖子了,但问题已通过将“构建操作”更改为 JSON 文件属性中的内容解决。
标签: c# authentication google-api windows-phone-8.1 gmail-api