Hi,
Problem/Motivation
Social login doesn't work.
I use Google, Twitter, Facebook.
When I click to a social icon on login page a popup is opened and then closed right away.
Drupal log contains one of the following messages depending on used provider:
- Your application id and secret are required in order to connect to Facebook.
- Your application key and secret are required in order to connect to Twitter.
- Your application id and secret are required in order to connect to Google.
- etc.
But I've already configured provider settings.
Affected version
The module versions: 6.x-2.0, 6.x-2.x
HybridAuth Library: 2.1.2 (latest stable)
Do you have ideas what is happening?
Thanks.
Comments
Comment #1
Konstantin Komelin commentedPatched the Oauth library as recommended in README. It's still not working.
Comment #2
duozerskKonstantin,
There is a "Debug mode" checkbox on the module settings page (on the last vertical tab or fieldset). Please enable it and check for the log file created at "temporary file system/hybridauth.debug.log". This log file should contain the dumps of the configuration information HybridAuth gets about the used provider. If it doesn't get your keys - then smth is wrong with delivering it to the library (provided these keys are saved and displayed successfully in the module admin settings).
Thanks
AndyB
Comment #3
Konstantin Komelin commentedThank you Andy I didn't know what debug flag does. But I enabled it right after the first issues.
Fragment of debug dump from log:
It seems like:
Comment #4
Konstantin Komelin commentedComment #5
duozerskYep, the keys are delivered as empty values. You should check why it happens - the function that gathers the provider config is hybridauth_get_provider_config() - http://drupalcode.org/project/hybridauth.git/blob/refs/heads/6.x-2.x:/hy... - you might want to set the debug output there to see if it ever gets to this function and what values it gets from the variables.
Thanks
AndyB
Comment #6
Konstantin Komelin commentedI've discovered the bug.
My server Nginx changes the case of urls, so that urls like this
http://domain/admin/user/hybridauth/provider/Facebook?destination=admin%2Fuser%2Fhybridauthbecome
http://domain/admin/user/hybridauth/provider/facebook?destination=admin%2Fuser%2FhybridauthAnd the fourth part is passed into the hybridauth_admin_provider_settings as $provider_id parameter.
There are some hardcode checks for popular providers like this:
So such condition doesn't work because 'facebook' != 'Facebook'.
First obvious fix is to add:
right at the top of the function.
But it wouldn't totally correct for example for 'MySpace' provider machine name.
The best fix would be to replace machine names of providers with their lowercase equivalents in function hybridauth_providers_list() and then add
at the top of the function hybridauth_admin_provider_settings().
What do you think? Is it suitable solution? If so I would provide a patch for D6.
Comment #7
duozerskNope,
The library itself requires provider code names to be like the classes implementing these providers were named (and probably the file names the implementation lives in).
class Hybrid_Providers_LinkedIn extends Hybrid_Provider_ModelSo I suppose the only solution is to change nginx config not to change the URLs.
AndyB
Comment #8
Konstantin Komelin commentedWe could imagine many solutions except that extreme one:
Okay thanks. I will look at it myself. You may close the issue if you think it 'works as designed'.
Comment #9
Konstantin Komelin commentedFound another solution. I suggest sending provider name as GET parameter.
Such links
http://domain/admin/user/hybridauth/provider/Facebook?destination=admin%2Fuser%2Fhybridauthwill be replaced with
http://domain/admin/user/hybridauth/provider?name=Facebook&destination=admin%2Fuser%2FhybridauthServer rewrite mechanism doesn't touch parameters because they are case sensitive.
Wdyt?
Comment #10
duozerskKonstantin,
I wouldn't go for the URLs change... What about implementing the menu argument loading function that will map even the lower-cased provider names to the needed ones?
AndyB
Comment #11
duozerskDone it for both D7 and D6.
D7 - http://drupalcode.org/project/hybridauth.git/commit/594e768
D6 - http://drupalcode.org/project/hybridauth.git/commit/d0e90de
Please try the snapshot code and see if it helps.
AndyB
Comment #12
Konstantin Komelin commentedExcellent solution Andy!
I've tested it on D6 site. It works fine.