您好我想阅读所有电子邮件,我创建了一个谷歌应用程序,如下所示
现在我通过以下代码进行测试。
public async Task ListLabels()
{
UserCredential credential = null; ;
using (var stream = new FileStream("client_secret_899062187155-oog0nddbvujerg5pdklp24clt25rg9ut.apps.googleusercontent.com.json", FileMode.Open, FileAccess.Read))
{
credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(GoogleClientSecrets.Load(stream).Secrets,
new[] { GmailService.Scope.GmailReadonly },
"user", CancellationToken.None);
}
var service = new GmailService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "Gmail Test",
});
try
{
ListLabelsResponse response = service.Users.Labels.List("me").Execute();
foreach (Label label in response.Labels.OrderBy(p => p.Name))
{
Console.WriteLine(label.Id + " - " + label.Name);
}
}
catch (Exception e)
{
Console.WriteLine("An error occurred: " + e.Message);
}
}
现在,我登录后出现错误
我无法确定需要设置的重定向网址。