2015-01-06 55 views
3

這是我以前的代碼在庫的幫助下。谷歌C#客戶端庫獲取刷新令牌

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 
      ) ; 

回答

1

控制器必須還標明異步並返回一個任務即

public async Task<IHttpActionResult> get(string token){ 
    //your code here 
} 
相關問題