• I’ve been able to get the login-with-google plugin working on my mutli-site WordPress installation by entering the client_id and secret in the Settings UI for each of the wordpress sites in my multi-site deployment. This was needed because I was unable to get the wp-config.php configuration settings to work.

    I added this to my wp-config.php

    /* https://www.ads-software.com/plugins/login-with-google/#description */
    define('WP_GOOGLE_LOGIN_CLIENT_ID', '7935-REDACTED-nbfu.apps.googleusercontent.com');
    define('WP_GOOGLE_LOGIN_SECRET', 'Tk-REDACTED-nh');
    define('WP_GOOGLE_LOGIN_USER_REGISTRATION', 'false');

    And I can confirm that the plugin is able to see these values because when I login using username/password and go to the login-with-google Settings UI, these 3 fields are greyed out and can’t be set, and the values that I’ve put in my wp-config.php are present in the fields in the Settings UI.

    The problem is that the plugin doesn’t seem to use these values if they’re configured in wp-config.php, only if they’re configured in the Settings UI.

    I’ve tested configuring the client_id in wp-config.php and found that the “Log in with Google” button on the login page, which is a link to start the OAuth flow, has an empty client_id value. This obviously causes the OAuth login to fail.

    I’ve also tested by setting the client_id in the plugin Settings UI and the secret in wp-config.php. In this case, the “Log in with Google” button is correct and has the client_id but the OAuth flow fails because the plugin isn’t aware of the secret.

    I’ve read through the code and am assuming that this relates to the utils/GoogleClient.php and the __construct method in the GoogleClient class. This sets the $this->client_id value using the $config array that’s passed in.

    The array that’s passed in when the object is instantiated is in src/Container.php in the define_services method of the Container class. I’m not familiar with the details here but I have to assumed that it’s only reading from the values set in the UI settings and ignoring anything set in wp-config.php

    This should be reproducible on your side, just set the client_id and secret in wp-config.php and see if you can login.

    If indeed you’re not able to reproduce this, let me know and I can share more details about my setup.

  • The topic ‘wp-config.php settings recognized but not used’ is closed to new replies.