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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T02:17:28+00:00 2026-05-31T02:17:28+00:00

As I am developing an exportation and importing into Google Calendar application with Codeigniter

  • 0

As I am developing an exportation and importing into Google Calendar application with Codeigniter and the Google apiService/apiCalendarService. I have everything set up perfectly, no problem with this, when I authorize my application with Google from this page:

enter image description here

The contained code is what happens when the redirect happens:

session_start();

require(APPPATH . 'libraries/google/apiClient.php');
require(APPPATH . 'libraries/google/contrib/apiCalendarService.php');

$apiClient = new apiClient();
$apiClient->setUseObjects(true);
$calendarService = new apiCalendarService($apiClient);

if(isset($_SESSION['oauth_access_token'])) 
{
    $apiClient->setAccessToken($_SESSION['oauth_access_token']);
} 
else 
{
    $token = $apiClient->authenticate();
    $_SESSION['oauth_access_token'] = $token;
}

After authenticating, I get redirected back to my localhost site with the options in my URL:

http://localhost/project/acp/sync/auth/?code=4/DS91JtSJ5_9Q-Z55Kpyh2AicyWdL

My script will detect when an authencation has been made by checking the URI segment with auth and a code query string – so I can start importing events to my Google Calendar account, until that I get this error thrown:

Fatal error: Uncaught exception 'apiServiceException' with message 'Error calling POST https://www.googleapis.com/calendar/v3/calendars/primary/events?key={removed API key}: (401) Login Required' in /Users/Me/Sites/project/application/libraries/google/io/apiREST.php:86
Stack trace:
#0 /Users/Me/Sites/project/application/libraries/google/io/apiREST.php(56): apiREST::decodeHttpResponse(Object(apiHttpRequest))
#1 /Users/Me/Sites/project/application/libraries/google/service/apiServiceResource.php(187): apiREST::execute(Object(apiServiceRequest))
#2 /Users/Me/Sites/project/application/libraries/google/contrib/apiCalendarService.php(493): apiServiceResource->__call('insert', Array)
#3 /Users/Me/Sites/project/application/controllers/acp/panel.php(2053): EventsServiceResource->insert('primary', Object(Event))
#4 [internal function]: Panel->sync('auth')
#5 /Users/Me/Sites/project/system/core/CodeIgniter.php(359): call_user_func_array(Array, Array)
#6 /Users/Me in /Users/Me/Sites/project/application/libraries/google/io/apiREST.php on line 86

The code that was importing an event (code came from Google API samples):

session_start();

require(APPPATH . 'libraries/google/apiClient.php');
require(APPPATH . 'libraries/google/contrib/apiCalendarService.php');

$apiClient = new apiClient();
$apiClient->setUseObjects(true);
$service = new apiCalendarService($apiClient);

$event = new Event();
$event->setSummary('Appointment');
$event->setLocation('Somewhere');
$start = new EventDateTime();
$start->setDateTime('2011-06-03T10:00:00.000-07:00');
$event->setStart($start);
$end = new EventDateTime();
$end->setDateTime('2011-06-03T10:25:00.000-07:00');
$event->setEnd($end);
$attendee1 = new EventAttendee();
$attendee1->setEmail('attendeeEmail');
// ...
$attendees = array($attendee1,
                   // ...
                  );
$event->attendees = $attendees;
$createdEvent = $service->events->insert('primary', $event);

echo $createdEvent->getId();

I tried Googling the error, but I don’t seem to find any solutions with this, do you know how I can fix this problem?

  • 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-31T02:17:30+00:00Added an answer on May 31, 2026 at 2:17 am

    You are getting a 401 Login Required because the second code is not setting the token:

    $apiClient->setAccessToken($_SESSION['oauth_access_token']);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Developing a heavily XML-based Java-application, I recently encountered an interesting problem on Ubuntu Linux.
developing iphone app, I have used a UIImageview and i have set an image
Developing a desktop application based on Java + Swing I faced the problem of
Developing a network application, I have a Connection class that manages sending and receiving
Developing an MVC application, i now need to have test other browser versions. Installed
Iam developing one application.In that i use the google api for getting the location
Iam developing one application.In that i use the google api for getting the location
Developing a little survey webapp, ran into problem that deals with ranges for rating
Developing a .NET WinForms application: how can I check if the window is in
Developing a website and just trying to get back into the swing of (clever)

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.