title: ASP.Net MVC 5 Google Authentication with Scope
body: <p>I'm trying to get ASP.Net MVC 5 Google OAuth2 authentication working correctly.</p>
  
  <p>When I set pass in a GoogleOauth2AuthenticationOptions without any scope, then I'm able to log in successfully.</p>
  
  <pre><code>var googlePlusOptions = new GoogleOAuth2AuthenticationOptions
  {
      ClientId = googleClientId,
      ClientSecret = googleClientSecret,
      SignInAsAuthenticationType = DefaultAuthenticationTypes.ExternalCookie,
      Provider = new GoogleOAuth2AuthenticationProvider()
      {
          OnAuthenticated = async ctx =&gt;
          {
              ctx.Identity.AddClaim(new Claim("urn:tokens:googleplus:accesstoken", ctx.AccessToken));
          }
      },
  };
  
  app.UseGoogleAuthentication(googlePlusOptions);
  </code></pre>
  
  <p>Then this call will return an ExternalLoginInfo object with all the properties set</p>
  
  <pre><code>ExternalLoginInfo loginInfo = await AuthenticationManager.GetExternalLoginInfoAsync();
  </code></pre>
  
  <p>When I <strong>add any scope</strong> though, then I don't get any login info returned. It's just null.</p>
  
  <pre><code>var googlePlusOptions = new GoogleOAuth2AuthenticationOptions
  {
      ClientId = googleClientId,
      ClientSecret = googleClientSecret,
      SignInAsAuthenticationType = DefaultAuthenticationTypes.ExternalCookie,
      Provider = new GoogleOAuth2AuthenticationProvider()
      {
          OnAuthenticated = async ctx =&gt;
          {
              ctx.Identity.AddClaim(new Claim("urn:tokens:googleplus:accesstoken", ctx.AccessToken));
          }
      },
  };
  
  googlePlusOptions.Scope.Add(YouTubeService.Scope.Youtube);
  
  app.UseGoogleAuthentication(googlePlusOptions);
  </code></pre>
  
  <p>Then the call to get external info just <strong>returns null</strong>.</p>
  
  <pre><code>ExternalLoginInfo loginInfo = await AuthenticationManager.GetExternalLoginInfoAsync();
  </code></pre>
  
  <p>In the Google dev console, I have the following APIs turned on..</p>
  
  <ul>
  <li>Analytics API</li>
  <li>BigQuery API</li>
  <li>Google Cloud SQL</li>
  <li>Google Cloud Storage</li>
  <li>Google Cloud Storage JSON API</li>
  <li>Google+ API</li>
  <li>Google+ Domains API</li>
  <li>Identity Toolkit API</li>
  <li>YouTube Analytics API</li>
  <li>YouTube Data API v3</li>
  </ul>
  
  <p>Something about adding scope to the options is breaking GetExternalLoginInfoAsync.</p>