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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:36:24+00:00 2026-06-14T10:36:24+00:00

I am trying to access the Google API v3 Calendarlist but I keep getting

  • 0

I am trying to access the Google API v3 Calendarlist but I keep getting 401/404 responses even though I have a valid AccessToken for the User.
(I completed the OAuth2 protocol for Web Server Applications and received the https://www.googleapis.com/auth/calendar permission)

It’s been rather difficult to find good documentation for this, the google site itself isn’t very helpful and searches are full of old v2 information or use SDKs. Usually I can make do with translating python replies to c# but in this case even that didn’t help me.

So I’m pulling my hair out but I’m probably forgetting something very simple here like a missing parameter or somesuch, so it would be greatly appreciated if someone would take a quick look at this code and tell me what I’m doing wrong.

var applicationKey = moduleModel.Application.Key;
var userID = moduleModel.User.UserID;
var accessToken = moduleModel.User.AccessToken.Token;

// It doesn't seem to make any difference whether I use the querystring
// parameter or the request header to specify the access_token
var sendAccessTokenAsHeader = 
    !(Request.QueryString["SendAccessTokenAsHeader"] == "0");

// I tried navigating to a specific user but it results in a 404 Not Found
var requestSpecificUserID = 
    Request.QueryString["RequestSpecificUserID"] == "1";

// Including or omitting my API_KEY doesn't seem to make any difference
var sendApplicationKey = 
    !(Request.QueryString["SendApplicationKey"] == "0");

var urlBuilder = new System.Text.StringBuilder();

urlBuilder.Append("https://");
urlBuilder.Append("www.googleapis.com");

if (requestSpecificUserID)
{
    urlBuilder.Append
        (string.Format("/calendar/v3/users/{0}/calendarList", userID));
}
else
{
    urlBuilder.Append
        ("/calendar/v3/users/me/calendarList");
}

var parameterJoiner = "?";

if (sendApplicationKey)
{
    urlBuilder.Append
    (
        string.Format
        (
            "{0}{1}={2}",
            parameterJoiner,
            "key",
            HttpUtility.UrlEncode(applicationKey)
        )
    );
    parameterJoiner = "&";
}

if (!sendAccessTokenAsHeader)
{
    urlBuilder.Append
    (
        string.Format
        (
            "{0}{1}={2}",
            parameterJoiner,
            "access_token",
            HttpUtility.UrlEncode(accessToken)
        )
    );
    parameterJoiner = "&";
}

var httpWebRequest = HttpWebRequest.Create(urlBuilder.ToString()) 
    as HttpWebRequest;
httpWebRequest.CookieContainer = new CookieContainer();

if (sendAccessTokenAsHeader)
{
    httpWebRequest.Headers["Authorization"] = string.Format
    (
        "Bearer {0}",
        accessToken
    );
}

// GetSafeResponse is just an extension method to catch the WebException 
// when the HttpStatusCode != OK

var response = httpWebRequest.GetSafeResponse(); 

// returns 401 (requestSpecificUserID = false)
// or 404 (requestSpecificUserID = true)

var responseText = response.GetResponseText();

return responseText;

Thank you in advance!

  • 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-06-14T10:36:25+00:00Added an answer on June 14, 2026 at 10:36 am

    I found my answer by reading this question.

    Apparently, even though the Google documentation does not mention it at all, the parameter minAccessRole is required.

    Working example:

    var accessToken = moduleModel.User.AccessToken.Token;
    
    var urlBuilder = new System.Text.StringBuilder();
    
    urlBuilder.Append("https://");
    urlBuilder.Append("www.googleapis.com");
    urlBuilder.Append("/calendar/v3/users/me/calendarList");
    urlBuilder.Append("?minAccessRole=writer");
    
    var httpWebRequest = HttpWebRequest.Create(urlBuilder.ToString()) 
        as HttpWebRequest;
    
    httpWebRequest.CookieContainer = new CookieContainer();
    httpWebRequest.Headers["Authorization"] = 
        string.Format("Bearer {0}", accessToken);
    
    var response = httpWebRequest.GetSafeResponse();
    
    var responseText = response.GetResponseText();
    
    return responseText;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to access my Google spreadsheets using the GData API. I have followed
I have a Google Search Appliance and am trying to access the API to
I'm learning to use google task api rest. i have succeed getting access tokken.
I'm trying to get access to the Google Drive API using RestKit on iOS
I am trying to access our site's Web usage statistics through Google Analytics API.
I'm using the Zend_Gdata_Photos PHP client to access the Google Picasa API, trying to
This is probably very basic but I'm trying to test the Google Places API.
My web application is based on Google Maps API and I have problems trying
I'm trying to get Google APi's access_token using c# and always getting error message
I'm trying to use the google-api-client gem to access the Google Search API for

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.