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 7072039
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:45:36+00:00 2026-05-28T05:45:36+00:00

I managed to get the access token for google’s contacts API but when i

  • 0

I managed to get the access token for google’s contacts API but when i try to make a call to retrieve the logged in user’s profile, i get a 401 unauthorized error…

I did some research and followed the steps mentioned in “various” google documentations ( like this one and this one and many others) but with no use…

So far i think i’m signing the request wrong. Here’s what i’m doing after i get the access token.

string outUrl,querystring;
string sig = oAuth.GenerateSignature(new Uri("https://www.google.com/m8/feeds/contacts/default/full"), Server.UrlEncode(oAuth.ConsumerKey), oAuth.ConsumerSecret, oAuth.Token, null, "GET", timeStamp, nonce, out outUrl, out querystring);
string reqURL = "https://www.google.com/m8/feeds/contacts/default/full?access_token=" + oAuth.Token + "&oauth_signature_method=HMAC-SHA1&oauth_signature=" + Server.UrlEncode(sig) + "&oauth_consumer_key=" + oAuth.ConsumerKey + "&oauth_timestamp=" + timeStamp + "&oauth_nonce=" + nonce + "&oauth_version=1.0";
response = oAuth.WebRequest(oAuthGoogle.Method.GET, reqURL, String.Empty);

The 401 error appears when send the request using oAuth.WebRequest() (the last line of the code above)

I just need to get rid of the 401 error…I’m using ASP.NET/C#. Any help would be appreciated. Thank you…

  • 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-28T05:45:37+00:00Added an answer on May 28, 2026 at 5:45 am

    Your code example defines reqURL which is not used and uses url which is not defined.

    You would normally provide OAuth request parameters with the authorization header rather than the querystring.

    http://oauth.net/core/1.0/#auth_header_authorization

    I would imagine signing the request and setting the Authorization this is something that’s being handled inside your OAuth object.

    To clarify

    I have used a method like this to sign http requests in my OAuth 1.0a implementation:

        /// <summary>
        /// Gets the authorization header.
        /// </summary>
        /// <param name="method">The method.</param>
        /// <param name="url">The URL of the request.</param>
        /// <param name="parameters">The parameters.</param>
        /// <returns>Authorization header</returns>
        public string GetAuthorizationHeader(string method, Uri url, NameValueCollection parameters)
        {
            parameters.Set("oauth_consumer_key", this.ConsumerKey);
            parameters.Set("oauth_nonce", this.GetNonce());
            parameters.Set("oauth_timestamp", this.GetTimeStamp());
            parameters.Set("oauth_version", "1.0");
            parameters.Set("oauth_signature_method", "HMAC-SHA1");
    
            string signString = this.GetSignString(method, url, parameters);
            string signature = this.GetSignature(signString, this.ConsumerSecret, this.tokenSecret);
    
            parameters.Set("oauth_signature", signature);
    
            StringBuilder authorizationHeader = new StringBuilder();
            foreach (string paramKey in parameters.AllKeys)
            {
                if (authorizationHeader.Length > 0)
                {
                    authorizationHeader.Append(", ");
                }
                else
                {
                    authorizationHeader.Append("OAuth ");
                }
    
                authorizationHeader.AppendFormat("{0}=\"{1}\"", paramKey, OAuthHelper.UrlEncode(parameters[paramKey]));
            }
    
            return authorizationHeader.ToString();
        }
    

    Which I use like this

        public void SignHttpWebRequest(string token, string tokenSecret, ref HttpWebRequest request)
        {
            NameValueCollection parameters = new NameValueCollection();
            this.tokenSecret = tokenSecret;
            parameters.Set("oauth_token", token);
            request.Headers.Add("Authorization", this.GetAuthorizationHeader(request, parameters));
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've successfully managed to get an OAuth access token and am able to make
Im getting a ProfileEntry for a logged in user. I've managed to get the
Is it possible to somehow get an access token to use the facebook api
I managed to get the YUI calendar widget working fine. But When it displays
Using django, I am authenticating the user through Google. I get the initial request
It took me some time, but I managed to get to the last point
I managed to get some help from a previous question and I have the
I managed to get a unsigned long int octets-representation (BE) by reading IPv4 methods,
I managed to get authentication to work by following the tutorial from this page
I've somehow managed to get an SVN repository into a bad state. I've moved

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.