0

The problem: I've just installed social_auth_google, social_auth_twitter and social_auth_linkedin modules. All the modules are configured (Client ID, Client Secret, and other similar fileds). The modules are installed through composer require ..., so I assume that all dependencies are there, but to confirm here's the list of the enabled modules:

Social Social API (social_api) Enabled 8.x-2.0-beta4 Social Social Auth (social_auth) Enabled 8.x-2.0-beta4 Social Social Auth Google Enabled 8.x-2.0-beta3 (social_auth_google) Social Social Auth LinkedIn Enabled 8.x-2.0-beta1 (social_auth_linkedin) Social Social Auth Twitter Enabled 8.x-2.0-alpha2 (social_auth_twitter)

Besides these, composer also installed some non-Drupal packages to vendor directory:

  • league/oauth2-client (2.3.0)
  • league/oauth2-google (2.2.0)
  • abraham/twitteroauth (0.9.2)
  • league/oauth2-linkedin (2.1.0)

I've embedded "Social Auth Login" block to "Content" region of /user/login and /user/register pages, and I've got a decent-looking login/register pages as the result.

But the problem is that neither of the embedded authentication providers doesn't work. If I click g+, I get "Error: invalid_request. Missing required parameter: client_id". When I click twitter, I get: "You could not be authenticated, please contact the administrator.". With LinkedIn I get: "You need to pass the 'client_id' parameter".

Obviously I'm missing something... Any help?

  • Please don't include links to your site. As it simply will become invalid once the issue got fixed. Apart from that it can be easily considered as spam aiming to gain some traffic and/or SEO juice. – leymannx Aug 11 '18 at 6:24
  • It's pretty obvious that you are missing an API key or something very similar. Please simply read the docs thoroughly, for example github.com/drupalsocialinitiative/social_auth_google/blob/… – leymannx Aug 11 '18 at 6:37
  • @leymannx - Thanks for the suggestion about link to my site. I've planned to remove it once it's fixed. And it definitely isn't about traffic/SEO - as you can see the site isn't available at all (access denied). – Aleksandar Pesic Aug 11 '18 at 18:24
  • 1
    Regarding API keys - I've set them all appropriately, for all the providers (g+, Twitter, LinkedIn). I've rechecked that. But for some reason it looks that social_auth simply doesn't send these. I hope that someone else have experience with the same issue... Thanks for trying to help! – Aleksandar Pesic Aug 11 '18 at 18:28
  • Hm I see, I see, thing is, debugging always needs to be done by you. The chance someone else had the problem as well is very low and would instead make this question better posted on drupal.org. Only you know the specific setup of your site and your server etc., that's why this issue is difficult to solve from afar, requiring lots of back and forth questioning in comments, which simply is too broad for a fact-based Q&A. As soon as you know the root cause of the issue and don't know how to solve it, feel free to come back and ask a new question. Good luck :) – leymannx Aug 11 '18 at 19:09
1

I've found the reason for the problem: outgoing proxy. The web server where I have my website installed doesn't have direct internet access, but it uses an outgoing proxy.

Regarding social_auth_twitter - it was my mistake - outgoing proxy was blocking access to api.twitter.com. After configuring the proxy to allow this traffic - Twitter authentication started working as expected.

But regarding the other two (social_auth_google and social_auth_linkedin) - no requests ever reached the proxy, meaning that these modules don't know how to use the proxy.

I've ensured that the proxy is configured correctly:

  • Environment variables http_proxy, https_proxy, no_proxy, HTTP_PROXY, HTTPS_PROXY, NO_PROXY are configured as needed;
  • In VirtualHost element (Apache configuration) I'm ensuring that these environment variables are available by setting the appropriate PassEnv lines (mod_env module);
  • settings.php file contains the appropriate $settings['http_client_config']['proxy']['http'] (and other) configuration.

At the end of the day - everything else (installing and updating modules, etc.) is working normally through the proxy, so proxy configuration isn't the problem.

It looks that, at least for now, you cannot have social_auth_google and social_auth_linkedin if your web server is behind a proxy. Another very disappointing fact is that there are no any logs in /admin/reports/dblog, so you cannot know that modules are struggling to access their corresponding API endpoints. Hopefully it'll be resolved in future versions. For now you simply have to allow direct access, and remove outgoing proxy completely.

1

For the sake of completeness, let me offer an alternative answer which will allow you to keep outgoing proxy in place.

After reviewing the code of both social_auth_google and social_auth_linkedin, I've concluded that they are both suffering from the same bug. And in both cases the bug is fixed in 2.x-dev version. But dev version doesn't work because of some other issue (a missing class issue), so I couldn't migrate to dev. Instead I've kept their latest beta versions, and fixed the bug manually. I'll explain the fix on social_auth_google module, but the same thing should be done with social_auth_linkedin also.

The bug is in social_auth_google/src/Plugin/Network/GoogleAuth.php file, in initSdk() method. Here's the snippet with the bug:

if ($this->validateConfig($settings)) { // All these settings are mandatory. $league_settings = [ 'clientId' => $settings->getClientId(), 'clientSecret' => $settings->getClientSecret(), 'redirectUri' => $this->requestContext->getCompleteBaseUrl() . '/user/login/google/callback', 'accessType' => 'offline', 'verify' => FALSE, 'hostedDomain' => $settings->getRestrictedDomain(), ];

// Proxy configuration data for outward proxy.
$proxyUrl = $this->siteSettings->get('http_client_config')['proxy']['http'];
if ($proxyUrl) {
    $league_settings = [
        'proxy' => $proxyUrl, 
    ];
}

return new Google($league_settings);

}

What's happening there is that, if an outgoing proxy is defined, instead of adding 'proxy' value to $league_settings variable, it overrides it completely. For this reason we don't have 'clientId' defined anymore, thus getting the error from the original question: "Missing required parameter: client_id".

So what we need to do is to simply change

if ($proxyUrl) { $league_settings = [ 'proxy' => $proxyUrl, ]; }

with

if ($proxyUrl) { $league_settings['proxy'] = $proxyUrl; }

After this change, and the same exact change in social_auth_linkedin module, both authentication providers will work.

  • Nice findings! You should definitely share them on drupal.org! – leymannx Aug 12 '18 at 20:57
  • @leymannx: Thanks! Regarding sharing on drupal.org - social_auth guyz are already aware of the bug (it's fixed in 2.x-dev version). Thanks for taking care of Drupalers here! :) – Aleksandar Pesic Aug 13 '18 at 18:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.