title: Accessing Google Docs with GData
body: <p>Working Platform: ASP.NET 4.0 C# ( Framework Agnostic )</p>
  
  <p>Google GData is my dependency</p>
  
  <pre><code>using Google.GData.Client;
  using Google.GData.Extensions;
  using Google.GData.Documents;
  </code></pre>
  
  <p>I have two pages Auth and List.</p>
  
  <p>Auth redirects to Google Server like this</p>
  
  <pre><code>public ActionResult Auth()
  {
      var target = Request.Url.ToString().ToLowerInvariant().Replace("auth", "list");
      var scope = "https://docs.google.com/feeds/";
      bool secure = false, session = true;
  
      var authSubUrl = AuthSubUtil.getRequestUrl(target, scope, secure, session);
      return new RedirectResult(authSubUrl);
  }
  </code></pre>
  
  <p>Now it reaches the List Page if Authentication is successful.</p>
  
  <pre><code>public ActionResult List()
  {
      if (Request.QueryString["token"] != null)
      {
          String singleUseToken = Request.QueryString["token"];
  
          string consumerKey = "www.blahblah.net";
          string consumerSecret = "my_key";
          string sessionToken = AuthSubUtil.exchangeForSessionToken(singleUseToken, null).ToString(); 
  
          var authFactory = new GOAuthRequestFactory("writely", "qwd-asd-01");
          authFactory.Token = sessionToken;
          authFactory.ConsumerKey = consumerKey;
          authFactory.ConsumerSecret = consumerSecret;
          //authFactory.TokenSecret = "";
          try
          {
              var service = new DocumentsService(authFactory.ApplicationName) { RequestFactory = authFactory };
  
              var query = new DocumentsListQuery();
              query.Title = "project";
  
              var feed = service.Query(query);
              var result = feed.Entries.ToList().ConvertAll(a =&gt; a.Title.Text);
              return View(result);
          }
          catch (GDataRequestException gdre)
          {
              throw;
          }
      }
  }
  </code></pre>
  
  <p>This fails at the line <code>var feed = service.Query(query);</code> with the error</p>
  
  <blockquote>
    <p>Execution of request failed: <a href="https://docs.google.com/feeds/default/private/full?title=project" rel="nofollow">https://docs.google.com/feeds/default/private/full?title=project</a></p>
  </blockquote>
  
  <p>The <code>HttpStatusCode</code> recieved on the catch block is <code>HttpStatusCode.Unauthorized</code></p>
  
  <p>What is wrong with this code? Do I need to get TokenSecret? If so how?</p>