title: Umbraco Async SurfaceController
body: <p>I am working on a project (ASP.NET MVC 5) where I am using Umbraco 7.4.3. I am trying to implement the google analytics api along with oauth2. I used the sample code available on the google documentation platform. After authorizing with my google account I get a correct refresh token. But the problem is this refresh token is returned in the URL and is not getting passed by my controller to my view which remains empty. I have a feeling that my controller does not wait to execute it's code after the user authorized his or her google account hence the controller is not bothered about the await operator.</p>
  
  <p><a href="https://developers.google.com/api-client-library/dotnet/guide/aaa_oauth#web-applications-aspnet-mvc" rel="nofollow">Link to the sample code</a></p>
  
  <pre><code>public class GoogleAnalyticsController : SurfaceController
  {
      public async Task&lt;ActionResult&gt; Add(CancellationToken cancellationToken) 
      {
          var result = await new AuthorizationCodeMvcApp(this, new AppFlowMetadata()).AuthorizeAsync(cancellationToken);
  
          if (result.Credential != null)
          {
              var service = new AnalyticsService(new BaseClientService.Initializer
                  {
                      HttpClientInitializer = result.Credential,
                      ApplicationName = "Analytics Dashboard"
                  });
  
              // YOUR CODE SHOULD BE HERE..
              ViewBag.AccessToken = result.Credential.Token.AccessToken;
              ViewBag.RefreshToken = result.Credential.Token.RefreshToken;
  
              var list = await service.Management.AccountSummaries.List().ExecuteAsync(cancellationToken);
              ViewBag.Username = list.Username;
  
              for (int i = 0; i &lt; list.TotalResults; i++)
              {
                  ViewBag.WebsiteNames += list.Items[i].Name + "(" + list.Items[i].WebProperties[0].WebsiteUrl + ")";
              }
  
              return View("~/Views/Configboard.cshtml");
          }
          else
          {
              return new RedirectResult(result.RedirectUri);
          }
      }
  </code></pre>
  
  <p>PS: I have tried this sample code out in a ASP.NET MVC 5 project without Umbraco installed which works perfectly.</p>
  
  <p>Any one able to push me into the right direction?</p>