XF 1.4 Twitter Integration

Valhalla

Well-known member
Hello,

What may cause using the "Log in with Twitter" button on the log-in form to work intermittently?

When using (testing) this feature, occasionally I will receive "An unexpected error occurred. Please try again later.", however, when trying again a few seconds later it will work as expected (requesting permission on Twitter).

One more thing, assuming everything works as expected, and you decide not to go ahead with the authorisation, and you click "Cancel", and then "Return to [site]", it will redirect you to an error message: "An unexpected error occurred. Please try again later".
 

Jeremy

Well-known member
Are there any errors logged into your site? Can you get this to work all the time with add-ons disabled?
 

Valhalla

Well-known member
Hi,

I disabled all add-ons on my site, and it was still performing intermittently - sometimes taking me to Twitter, sometimes returns with the error. (I kept trying it for a while with add-ons disabled.)

Then I re-enabled add-ons, with the same result. A while later, it began working more solidly, but I observe it still returns the error maybe 10% of the time.

There were no server error logs, apart from three all the same. I received these ones before disabling add-ons (before posting this thread) during one of the times it *did* successfully take me to Twitter. When I clicked "Sign In", it redirected me to my site, with the error here:

Server Error

Error in HTTP request

Zend_Oauth_Http->startRequestCycle() in Zend/Oauth/Http/AccessToken.php at line 51
Zend_Oauth_Http_AccessToken->execute() in Zend/Oauth/Consumer.php at line 225
Zend_Oauth_Consumer->getAccessToken() in XenForo/ControllerPublic/Register.php at line 803
XenForo_ControllerPublic_Register->actionTwitter() in XenForo/FrontController.php at line 347
XenForo_FrontController->dispatch() in XenForo/FrontController.php at line 134
XenForo_FrontController->run() in ../index.php at line 13
Detailed error:

Error Info
Zend_Oauth_Exception: Error in HTTP request - library\Zend\Oauth\Http.php:178
Generated By: Unknown Account, Today at 7:50 PM
Stack Trace
#0 ...\library\Zend\Oauth\Http\AccessToken.php(51): Zend_Oauth_Http->startRequestCycle(Array)
#1 ...\library\Zend\Oauth\Consumer.php(225): Zend_Oauth_Http_AccessToken->execute()
#2 ...\library\XenForo\ControllerPublic\Register.php(803): Zend_Oauth_Consumer->getAccessToken(Array, Object(Zend_Oauth_Token_Request))
#3 ...\library\XenForo\FrontController.php(347): XenForo_ControllerPublic_Register->actionTwitter()
#4 ...\library\XenForo\FrontController.php(134): XenForo_FrontController->dispatch(Object(XenForo_RouteMatch))
#5 ...\index.php(13): XenForo_FrontController->run()
#6 {main}
Request State
array(3) {
["url"] => string(142) "http://example.com/register/twitter?oauth_token=(removed)&oauth_verifier=(removed)"
["_GET"] => array(2) {
["oauth_token"] => string(32) "(removed)"
["oauth_verifier"] => string(32) "(removed)"
}
["_POST"] => array(0) {
}
}
I didn't get that error (immediately above) all the time I tried though, sometimes it actually worked, and I connected my Twitter account with the forum account.

Lastly, the whole process is very slow. "Redirecting you back to the application" seems to take ten seconds.

(By the way, the last thing I mentioned in my first post is actually reproducible on this site, but I'm not sure if that error is designed, rather than returning you to the site as suggested.)

Thanks,
 

Jeremy

Well-known member
I missed that comment about this site. It isn't designed, but if it is taking ~10 seconds to redirect back when it does work, it is likely some service issues with Twitter that are ultimately outside the control of the software.
 

Valhalla

Well-known member
Something similar is happening with Facebook log-in.

Clicking "Log in with Facebook" as a guest (or "Associate with Facebook" from Your Account when logged-in) redirects me to Facebook as expected.

When clicking "OK" to confirm access, it redirects me back to my site with the message "An error occurred while connecting with Facebook. Please try again later".
 

Valhalla

Well-known member
I'm still trying to resolve this problem. I haven't been able to offer this option of log-in or sign-up yet because of the number of times it tends to fail.

The actual error (although not logged) behind the "An unexpected error occurred. Please try again later" message is below.

Some other details:
- The forum in which this is occurs is running XenForo 1.4.2.
- I have received this error when all add-ons were disabled.
- I created a test forum on the same server and did not receive any errors. The Twitter integration worked well each time I tried it (of course, modifying the Website URL value within the Twitter App Settings.). I had no errors on the separate test forum. The test forum I created was using XenForo version 1.4.3 (I haven't had opportunity to check if anything was changed - just a thought.)

exception 'Zend_Http_Client_Adapter_Exception' with message 'Unable to Connect to ssl://api.twitter.com:443. Error #0: ' in .\library\Zend\Http\Client\Adapter\Socket.php:235

Stack trace:

#0 .\library\Zend\Http\Client.php(973): Zend_Http_Client_Adapter_Socket->connect('api.twitter.com', 443, true)
#1 .\library\Zend\Oauth\Http\RequestToken.php(160): Zend_Http_Client->request()
#2 .\library\Zend\Oauth\Http.php(175): Zend_Oauth_Http_RequestToken->_attemptRequest(Array)
#3 .\library\Zend\Oauth\Http\RequestToken.php(51): Zend_Oauth_Http->startRequestCycle(Array)
#4 .\library\Zend\Oauth\Consumer.php(115): Zend_Oauth_Http_RequestToken->execute()
#5 .\library\XenForo\ControllerPublic\Register.php(775): Zend_Oauth_Consumer->getRequestToken()
#6 .\library\XenForo\FrontController.php(347): XenForo_ControllerPublic_Register->actionTwitter() #7 .\library\XenForo\FrontController.php(134): XenForo_FrontController->dispatch(Object(XenForo_RouteMatch))
#8 .\index.php(13): XenForo_FrontController->run()
#9 {main} Next exception 'Zend_Oauth_Exception' with message 'Error in HTTP request' in .\library\Zend\Oauth\Http.php:178

Stack trace:

#0 .\library\Zend\Oauth\Http\RequestToken.php(51): Zend_Oauth_Http->startRequestCycle(Array)
#1 .\library\Zend\Oauth\Consumer.php(115): Zend_Oauth_Http_RequestToken->execute()
#2 .\library\XenForo\ControllerPublic\Register.php(775): Zend_Oauth_Consumer->getRequestToken()
#3 .\library\XenForo\FrontController.php(347): XenForo_ControllerPublic_Register->actionTwitter()
#4 .\library\XenForo\FrontController.php(134): XenForo_FrontController->dispatch(Object(XenForo_RouteMatch))
#5 .\index.php(13): XenForo_FrontController->run()
#6 {main}
Thank you,
 

Valhalla

Well-known member
I believe this to be related to PHP configuration - although I haven't narrowed it down completely just yet.

(My live forum, where I received the intermittent error, was using PHP 5.6, while the test forum, where I received no errors, was using PHP 5.4.)

I just changed the PHP instance of my live site, and it seems to work.
 

Valhalla

Well-known member
Hello,

I have again reached the problem detailed above when attempting to use the in-built Twitter integration using PHP 5.6.0 (this is on a Windows server, and it's a separate instance to my live forum which has used this feature on PHP 5.3 and 5.4 without any problems).

Running the Twitter Integration test (?tools/test-twitter) returns in one of a series of errors:

Either simply:

Twitter returned the following error: Error in HTTP request.
Or something similar to this:

Twitter returned the following error: Could not retrieve a valid Token response from Token URL: <?xml version="1.0" encoding="UTF-8"?> <hash> <error>Desktop applications only support the oauth_callback value 'oob'</error> <request>/oauth/request_token?oauth_consumer_key=5BuAZ8mDivYxe6hBPS1l32MBh&amp;oauth_nonce=9ec132adc8c2a5ab536c540f1llaf398&amp;oauth_timestamp=1424536482&amp;oauth_signature_method=HMAC-SHA1&amp;oauth_version=1.0&amp;oauth_callback=http%3A%2F%2Fexample.com%2Fadmin.php%3Ftools%2Ftest-twitter&amp;oauth_signature=w9D5bqpOMl9dCg3vMmt6806MyBk%3D</request> </hash> .
I do not believe it to be a problem with my Twitter app settings.
The test forum on which I am trying this on does not have any add-ons installed (XF 1.4.3).

(A similar problem occurs with the Facebook integration feature - errors are returned instead of the integration being successful.)

I shall update this thread should I find a solution.
 
Last edited:

Valhalla

Well-known member
I shall update this thread should I find a solution.
Yes, I appeared not to have put a Callback URL as part of the App settings. It appears to be working now.

(Although I can't explain the earlier problems because I'm sure I tried with and without a Callback URL countless times.)
 

Valhalla

Well-known member
Yes, I appeared not to have put a Callback URL as part of the App settings. It appears to be working now.

(Although I can't explain the earlier problems because I'm sure I tried with and without a Callback URL countless times.)
It appears those events were merely fortuitous.

When testing Twitter/Facebook integrations, sometimes it will work, sometimes it will not. I receive error messages such as:

- Your server could not connect to Facebook (https://graph.facebook.com). Try again later. If the issue persists, contact your host.
- Twitter returned the following error: Error in HTTP request.

(My XF Server Error log has errors from members trying to use the feature.)

Server Error Log
Error Info
Zend_Oauth_Exception: Error in HTTP request - library\Zend\Oauth\Http.php:178
Generated By: Unknown Account, Today at 12:51 AM
Stack Trace
#0 \library\Zend\Oauth\Http\AccessToken.php(51): Zend_Oauth_Http->startRequestCycle(Array)
#1 \library\Zend\Oauth\Consumer.php(225): Zend_Oauth_Http_AccessToken->execute()
#2 \library\XenForo\ControllerPublic\Register.php(805): Zend_Oauth_Consumer->getAccessToken(Array, Object(Zend_Oauth_Token_Request))
#3 \library\XenForo\FrontController.php(347): XenForo_ControllerPublic_Register->actionTwitter()
#4 \library\XenForo\FrontController.php(134): XenForo_FrontController->dispatch(Object(XenForo_RouteMatch))
#5 \index.php(13): XenForo_FrontController->run()
#6 {main}
Request State
array(3) {
["url"] => string(142) "http://example.com/register/twitter?oauth_token=(removed)&oauth_verifier=(removed)"
["_GET"] => array(2) {
["oauth_token"] => string(32) "(removed)"
["oauth_verifier"] => string(32) "(removed)"
}
["_POST"] => array(0) {
}
}
 

Mike

XenForo developer
Staff member
It seems like there are outgoing connectivity issues -- both of those errors seem to point to that. Unfortunately it's hard to say what specifically would be causing that. It's lower level than XenForo (it's mostly related to your network stack).
 

Breixo

Well-known member
I do believe so (just checked again too).

Just to note that on the occasions it does work, clicking on 'Run Test' does not immediately direct me to Twitter/Facebook to authenticate - it hangs for a while, then either takes me to Twitter/Facebook or produces the error similar to above.
I was having the same problem.
Just unticked "Enable Callback Locking" and it started to work correctly:
View attachment 167193

PS: I know it's been a long time ago, but hope this can help people like me who was having the same problem now ;)
 

trapped_soul

Well-known member
Hello,

What may cause using the "Log in with Twitter" button on the log-in form to work intermittently?

When using (testing) this feature, occasionally I will receive "An unexpected error occurred. Please try again later.", however, when trying again a few seconds later it will work as expected (requesting permission on Twitter).

One more thing, assuming everything works as expected, and you decide not to go ahead with the authorisation, and you click "Cancel", and then "Return to [site]", it will redirect you to an error message: "An unexpected error occurred. Please try again later".
I was having the same problem.
Just unticked "Enable Callback Locking" and it started to work correctly:
View attachment 167193

PS: I know it's been a long time ago, but hope this can help people like me who was having the same problem now ;)
We've started getting a lot of these this week, unfortunately the above suggestion is unticked so can't nail it down to that.
The error is Oauth and http request. Bit frustrating as we're not sure how to fix it or what is triggering it
 

trapped_soul

Well-known member
Just tested it again and it failed with "an unknown error occurred" but when I refreshed the page it worked, took me to Twitter for authorisation then back to the site. I logged out and logged in with Twitter - all fine.
Anyone know what would cause the initial error?
 

skicomau

Active member
I recently re-configured my Google, Facebook & Twitter logins after a server migration and going secure.

Notes:

1. They now all expect your web application (aka forum) to be https, if it's not, you are pushing a barrow uphill.

2. Facebook App config is nuanced. Many settings have to be exactly right.
Specifically you must have valid OAuth redirect URI's configured absolutely correctly in the Facebook App Admin. (FB App Admin -> Facebook Login -> Settings)
Also, in Advanced settings (FB App Admin -> Settings -> Advanced)
ensure that;
Native of desktop app is 'No'
Security IP whitelist is correct server IP
Domain Manager has correct URI path including correct protocol (http:// or https://)

3. Not knowing your server setup - but it is worth checking that your Curl ca bundle certificate is current and up to date. If it is out of date this may* explain the intermittent connections.

in php.ini

Code:
;extension=pdo_dblib.so
;Curl ca bundle certificate
curl.cainfo="/server/path/to../common/openssl/certs/curl-ca-bundle.crt"
* not sure if XF framework uses curl for connecting the OAuth stuff - but worth ensuring the ca-bundle.crt is up to date regardless.
 

trapped_soul

Well-known member
3. Not knowing your server setup - but it is worth checking that your Curl ca bundle certificate is current and up to date.
Thanks for the replies, have gone through quite a few things and all I can find right now is, errors related to OSCP in the SSL chain and that could well be the issue as the secure connection may fail.
 
Top