Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6587051
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:52:08+00:00 2026-05-25T16:52:08+00:00

Working Platform: ASP.NET 4.0 C# ( Framework Agnostic ) Google GData is my dependency

  • 0

Working Platform: ASP.NET 4.0 C# ( Framework Agnostic )

Google GData is my dependency

using Google.GData.Client;
using Google.GData.Extensions;
using Google.GData.Documents;

I have two pages Auth and List.

Auth redirects to Google Server like this

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

Now it reaches the List Page if Authentication is successful.

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 => a.Title.Text);
            return View(result);
        }
        catch (GDataRequestException gdre)
        {
            throw;
        }
    }
}

This fails at the line var feed = service.Query(query); with the error

Execution of request failed: https://docs.google.com/feeds/default/private/full?title=project

The HttpStatusCode recieved on the catch block is HttpStatusCode.Unauthorized

What is wrong with this code? Do I need to get TokenSecret? If so how?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T16:52:08+00:00Added an answer on May 25, 2026 at 4:52 pm

    Used the 3-legged OAuth in the Google Data Protocol Client Libraries

    Sample Code

    string CONSUMER_KEY = "www.bherila.net";
    string CONSUMER_SECRET = "RpKF7ykWt8C6At74TR4_wyIb";
    string APPLICATION_NAME = "bwh-wssearch-01";
    
    string SCOPE = "https://docs.google.com/feeds/";
    
    public ActionResult Auth()
    {
        string callbackURL = String.Format("{0}{1}", Request.Url.ToString(), "List");
        OAuthParameters parameters = new OAuthParameters()
        {
            ConsumerKey = CONSUMER_KEY,
            ConsumerSecret = CONSUMER_SECRET,
            Scope = SCOPE,
            Callback = callbackURL,
            SignatureMethod = "HMAC-SHA1"
        };
    
        OAuthUtil.GetUnauthorizedRequestToken(parameters);
        string authorizationUrl = OAuthUtil.CreateUserAuthorizationUrl(parameters);
        Session["parameters"] = parameters;
        ViewBag.AuthUrl = authorizationUrl;
        return View();
    }
    
    public ActionResult List()
    {
        if (Session["parameters"] != null)
        {
            OAuthParameters parameters = Session["parameters"] as OAuthParameters;
            OAuthUtil.UpdateOAuthParametersFromCallback(Request.Url.Query, parameters);
    
            try
            {
                OAuthUtil.GetAccessToken(parameters);
    
                GOAuthRequestFactory authFactory = new GOAuthRequestFactory("writely", APPLICATION_NAME, parameters);
    
                var service = new DocumentsService(authFactory.ApplicationName);
                service.RequestFactory = authFactory;
    
                var query = new DocumentsListQuery();
                //query.Title = "recipe";
    
                var feed = service.Query(query);
                var docs = new List<string>();
                foreach (DocumentEntry entry in feed.Entries)
                {
                    docs.Add(entry.Title.Text);
                }
                //var result = feed.Entries.ToList().ConvertAll(a => a.Title.Text);
                return View(docs);
            }
            catch (GDataRequestException gdre)
            {
                HttpWebResponse response = (HttpWebResponse)gdre.Response;
    
                //bad auth token, clear session and refresh the page
                if (response.StatusCode == HttpStatusCode.Unauthorized)
                {
                    Session.Clear();
                    Response.Write(gdre.Message);
                }
                else
                {
                    Response.Write("Error processing request: " + gdre.ToString());
                }
                throw;
            }
        }
        else
        {
            return RedirectToAction("Index");
        }
    }
    

    This 2-legged sample never worked for me for google docs.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Coding Platform ASP.NET 4.0 WebForms I have two pages that are relevant here Login.aspx
I am working on ASP.NET3.5 platform. I have used a file upload control and
The project is developed using ASP.NET MVC framework and heavily relies on .NET 3.5.
If a group of developers are working on a project written using ASP.net and
Currently our team of 11 people is working on a project on asp.net platform.
I'm working on a project for the .net platform and would like to support
As an ASP.NET developer, I'm used to working with how VS/C# transparently autogens proxy
I'm kind of new to the .NET platform. And currently I'm learning ASP.NET MVC.
I am entering mobile development. I have been working primarily in .NET since 1.0
Microsoft provides a number of command line tools for working with asp.net applications. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.