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

  • Home
  • SEARCH
  • 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 8067771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T12:26:09+00:00 2026-06-05T12:26:09+00:00

I am loading the google-api-php-client library (for oauth 2.0 usage) in my codeigniter project.

  • 0

I am loading the google-api-php-client library (for oauth 2.0 usage) in my codeigniter project. I would like to have a series of configuration values defined in a config file so that they can be used with this library. I am, however, noticing that the configuration info for the library is loaded before the config file that I have defined.

For example, in autoload.php, I have set the config autoloads as follows:

$autoload['config'] = array('my_config_file');

Within my_config_file.php I have a series of define statements to set the config values:

define('GOOGLE_OAUTH_APPLICATION_NAME','My Application Name');
define('GOOGLE_OAUTH_CLIENT_ID','My App Client ID');
define('GOOGLE_OAUTH_CLIENT_SECRET','My App Client Secret');

I would like to use these in the config for the google-api-php-client library:

global $apiConfig;
$apiConfig = array(
    'application_name' => GOOGLE_OAUTH_APPLICATION_NAME,
    'oauth2_client_id' => GOOGLE_OAUTH_CLIENT_ID,
    'oauth2_client_secret' => GOOGLE_OAUTH_CLIENT_SECRET
);

After doing this (and some debugging), I’ve determined that the config file for the library is executed before the autoloaded config file. This is further shown by the errors I get:

Notice: Use of undefined constant GOOGLE_OAUTH_APPLICATION_NAME ...
Notice: Use of undefined constant GOOGLE_OAUTH_CLIENT_ID ...
Notice: Use of undefined constant GOOGLE_OAUTH_CLIENT_SECRET ...

How do I get it so that these global config constants are defined before the library config is loaded (thus resolving this issue)?

  • 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-05T12:26:11+00:00Added an answer on June 5, 2026 at 12:26 pm

    Best practice is to create a separate config file for a library; say application/config/oauth.php.

    That config file gets loaded in the constructor of your library with $this->config->load('oauth');. Of course, you can also just include it in the autoload array.

    In your library, you then call the config items thusly:

    $apiConfig = array(
        'application_name' => $this->config->item('google_oauth_application_name', 'oauth'),
        'oauth2_client_id' => $this->config->item('oauth2_client_id', 'oauth'),
        'oauth2_client_secret' => $this->config->item('oauth2_client_secret', 'oauth')
    );
    

    Cheers.

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

Sidebar

Related Questions

I have a view containing a UIWebView which is loading a google map (so
I have problem with google map Loading and making center in my java script
I'm using jQuery version 1.7.1 from Google CDN and have the following code: $(menuInstance).delay(2000).removeClass('loading').html(ul);
I have a problem loading google map. In my head section I have the
I got a problem with loading the google maps api. I got my own
I am new to google maps api. I'd like suggestions on achieving the following
I am having an issue loading Google Maps API V3 in internet explorer. Here's
I am working on PHP wrapper for Google Image Charts API service. It supports
I am loading Google API using google.load() and I need to process some of
I'm loading reCAPTCHA via JavaScript http://www.google.com/recaptcha/api/js/recaptcha_ajax.js and am using jquery-1.5.2.min.js to communicate with a

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.