这是我以前在图书馆帮助下的代码。
UserCredential credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.Load(stream).Secrets,
new[] {
GmailService.Scope.GmailCompose, GmailService.Scope.GmailModify, GmailService.Scope.GmailReadonly
},
"user",
CancellationToken.None
) ;
我在ASP.NET MVC 4应用程序中使用它。在此声明中,它挂起浏览器。我尝试放置日志,没有异常,也没有进一步执行。我查看了this问题,由于它是异步操作,我切换到Visual Studio 2013.但仍然是同样的事情。
更新的代码:
UserCredential credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.Load(stream).Secrets,
new[] {
GmailService.Scope.GmailCompose, GmailService.Scope.GmailModify, GmailService.Scope.GmailReadonly
},
"user",
CancellationToken.None
) ;
答案 0 :(得分:1)
控制器还必须标记为异步并返回任务,即
public async Task<IHttpActionResult> get(string token){
//your code here
}