title: GET call to a Google API responds with "Unauthorized"
body: <p><strong>UPDATE: Figured this out.  I DID need to add the authorization header as answered below but I also believe the issue for my particular use case is that the access token (which I verified through Postman) required more scopes to authenticate me fully, which makes sense since this API contains surveys that I am trying to access, which are also linked to a Google account. Once I added the extra scopes needed to access the surveys to the token request along with the authorization header code below I was able to connect successfully.</strong></p>
  
  <p><strong>More info on adding scopes to C# code can be found here: <a href="http://www.oauthforaspnet.com/providers/google/" rel="nofollow">http://www.oauthforaspnet.com/providers/google/</a></strong></p>
  
  <p><strong>Hope this helps anyone running into similar issues. Thanks all!</strong></p>
  
  <p>I am trying to make a GET call to a Google API but it keeps responding with "Unauthorized" while I am logged in to Gmail. I've already implemented Google+ Sign-In in StartUp.Auth.cs and even saved the access token for later use.</p>
  
  <p>So how do I get the HttpClient to authorize me?  </p>
  
  <p>I have an access token available but I do not know how to pass it in properly.  I've seen examples with usernames and passwords, but I should not need to pass those parameters if I already have an access token?  If anything, I should be able to have the user redirected to a login page instead if needed when I log out before running the solution.</p>
  
  <p>What I am expecting when the project is run, is the result of the GET call to come back in the form of json but it always says I'm "Unauthorized" and I am probably missing 1 line of code somewhere...</p>
  
  <p>Here is the code I am using:</p>
  
  <pre><code>using (HttpClient client = new HttpClient())
  {
      string _url = "https://www.googleapis.com/consumersurveys/v2/surveys?key={MY_API_KEY}";
      client.BaseAddress = new Uri(_url);
      client.DefaultRequestHeaders.Accept.Clear();
      client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
  
      using (HttpResponseMessage response = client.GetAsync(_url).Result)
      {
          if (response.IsSuccessStatusCode)
          {
              using (HttpContent content = response.Content)
              {
                  var Content = content.ReadAsStringAsync();
                  ViewBag.GoogleResponse = Content.ToString();
              }
          }
          else
          {
              // THIS IS ALWAYS UNAUTHORIZED!
              ViewBag.GoogleResponse = response.StatusCode + " - " + response.ReasonPhrase;
          }
      }
  }
  </code></pre>
  
  <p>Please help with ideas or suggestions. Thanks!</p>