我已按照此处的教程使用 Google 登录并在 ASP.Net MVC 应用程序中访问 GMail API。
但是在这一行我的程序被卡住了,我的意思是没有响应,我想来自谷歌服务器。
var result = await new AuthorizationCodeMvcApp(this, new AppAuthFlowMetadata()).
AuthorizeAsync(cancellationToken);
我不知道为什么授权用户请求需要时间。
我已按照此处的教程使用 Google 登录并在 ASP.Net MVC 应用程序中访问 GMail API。
但是在这一行我的程序被卡住了,我的意思是没有响应,我想来自谷歌服务器。
var result = await new AuthorizationCodeMvcApp(this, new AppAuthFlowMetadata()).
AuthorizeAsync(cancellationToken);
我不知道为什么授权用户请求需要时间。
async和await关键字。这些关键字虽然在 VS2010 中被支持为CTP,但在 .Net Framework 4 的 VS 2010 中实际上并不适用。很简单的解决方案,我想,我应该早点想出来:(
我不确定你的具体问题是什么。我已使用以下内容访问 Gmail API。
// Create OAuth Credential.
UserCredential credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
new ClientSecrets
{
ClientId = "CLIENT_ID",
ClientSecret = "CLIENT_SECRET"
},
new[] { GmailService.Scope.GmailModify },
"me",
CancellationToken.None).Result;
// Create the service.
var service = new GmailService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "Draft Sender",
});
ListDraftsResponse draftsResponse = service.Users.Drafts.List("me").Execute();
IList<Draft> drafts = draftsResponse.Drafts;