Problem/Motivation

I'm experiencing fatal PHP error on loading URL:

http://domain/hybridauth/window/Twitter?destination=user/login&destination_error=user/login

The error message:

PHP Fatal error:  Cannot redeclare class OAuthConsumer in /var/www/sites/domain/sites/all/modules/oauth/lib/OAuth.php on line 20

Comments

duozersk’s picture

Assigned: Unassigned » duozersk
Status: Active » Closed (won't fix)

Konstantin,

Thanks for the report.
Yep, HybridAuth library is not compatible with the OAuth module. It can't be fixed by this module code, only on the HybridAuth library level.
See also #1942376: Problems with twitter and linkedin and #2130301: Linkedin authentication doesn't work with Twitter module.

Thanks
AndyB

Konstantin Komelin’s picture

Could you please inform users about this issue through the project page?

duozersk’s picture

Sure, added it to the project page.

Konstantin Komelin’s picture

Thank you Andy.

duozersk’s picture

Component: Code » HybridAuth library
Status: Closed (won't fix) » Closed (fixed)

This issue should be fixed by https://github.com/hybridauth/hybridauth/pull/244 - it is already included in the HybridAuth library release v2.2.2

AndyB

m3chas’s picture

I have the library 2.2.2 but still getting the error message, any idea?

duozersk’s picture

Status: Closed (fixed) » Active
tce’s picture

I'm using library v2.3.0 and getting the error message: Fatal error: Cannot redeclare class OAuthSignatureMethod_HMAC_SHA1

Update: Probably not the best way to do it but in the hybridauth library file Provider_Model_OAuth1.php I changed:

<?php
	// 2 - include OAuth lib and client
	require_once Hybrid_Auth::$config["path_libraries"] . "OAuth/OAuth.php";
	require_once Hybrid_Auth::$config["path_libraries"] . "OAuth/OAuth1Client.php";
?>

to this:

<?php
	// 2 - include OAuth lib and client
        if (! class_exists('OAuthConsumer') ) {
          require_once Hybrid_Auth::$config["path_libraries"] . "OAuth/OAuth.php";
        }
        require_once Hybrid_Auth::$config["path_libraries"] . "OAuth/OAuth1Client.php";
?>

Seems to be working now.

Anonymous’s picture

Status: Active » Reviewed & tested by the community

The solution in #8 works.

bdupls’s picture

I tried Solution #8 and the error changes to.

Fatal error: Class 'Hybrid_Exception' not found in /home/xxx/public_html/sites/all/libraries/hybridauth/Hybrid/Endpoint.php on line 213
This error seems to be a duplication of the error on this page which is not solved.
https://www.drupal.org/node/2130301

m faheem’s picture

I am also getting the same error, I have upgraded the libraries as well, but still the same issue
Fatal error: Class 'Hybrid_Exception' not found in /srv/bindings/f21e6f9ba0904ef08b56e352cad1a099/code/sites/all/libraries/hybridauth/Hybrid/Endpoint.php on line 205

duozersk’s picture

duozersk’s picture

Assigned: duozersk » Unassigned
Status: Reviewed & tested by the community » Needs work
kgaut’s picture

Hi,

I was facing the same issue, so I did a PR with #8 on HybridAuth : https://github.com/hybridauth/hybridauth/pull/560

Thanks for the solution.

StorytellerCZ’s picture

Status: Needs work » Needs review

Fixed in HybridAuth v2.5.1, please update.

roborew’s picture

Bumping this as have just ran into the same issue with facebook integration:

Fatal error: Cannot redeclare class OAuthSignatureMethod_HMAC_SHA1 in ../sites/all/libraries/hybridauth/hybridauth/Hybrid/thirdparty/OAuth/OAuth.php on line 139

The OAuthSignatureMethod_HMAC_SHA1 class is being declared twice as I have Oauth installed for the twitter module. Looks like this approach #1839636: Using HybridAuth with PECL OAuth would likely provide a hacky fix for the issue to get around the problem.

roborew’s picture

Status: Needs review » Active