It appears that the Twitter module does not pass an oauth_callback parameter when creating connections (authorising accounts).

This is an issue on multi-domain sites that share the same code base and database.

Twitter allows multiple domains to be authorised for callbacks, however, unless a client actually passes oauth_callback these are clearly not used and the default callback will be. Say these sites share the same code and database:

exampleone.com
egtwo.com

A developer picks exampleone.com as the default callback on the twitter config (http://exampleone.com/twitter/oauth) but also authorises egtwo.com.

When a user on egtwo.com links their account, oauth_callback should be sent to Twitter to have it return the user to http://egtwo.com/twitter/oauth but this is not done. The user actually ends up on http://exampleone.com/twitter/oauth which sees an invalid request and the account link is not finalised.

At the very least it would be nice if the module checked a config variable that one could set in their multi-site settings.php which would only be used if present.

The only other workaround would be to create many Twitter aps - one for each multi-site domain which isn't nice.

Comments

skizzo’s picture

subscribing.

Having similar problem with:
one.example.com
two.example.com
...

pedrosp’s picture

Subscribing

raintonr’s picture

+1 for this.

We have a family of sites using the same codebase and database on different domains (standard Drupal multisite setup), but it would be annoying to have to create a twitter application for each site.

At the moment they cannot share the same Twitter application though and everyone has to login and authorise on one specific site in the family which is configured on dev.twitter.com.

This issue would solve that problem.

raintonr’s picture

So... I had a quick look at this.

Reading the Twitter doco seems that if one wants to use the non-default callback it has to be setup in the initial token request.

That means a change to the function get_request_token in twitter.lib.php.

I did try quickly modifying this to pass an array of params (array('oauth_callback' => 'example.com')) to auth_request but that didn't work.

Any suggestions?

raintonr’s picture

Status: Active » Needs review

LOL... my bad. Just had a thought about what I did and turns out constructed the array incorrectly in the code (was correct in the comment). Fixed that up and yes, it does work. Hurrah!

To make this change, simply edit twitter.lib.php and change line 291 from this:

      $response = $this->auth_request($url);

To this:

      $response = $this->auth_request($url,array('oauth_callback' => url('twitter/oauth', array('absolute' => true))));
michaek’s picture

I'm surprised that specifying a different domain in the callback is allowed, as I would have thought Twitter would restrict that. However, I think it could be desirable to test this and get it into the module. Could you roll a patch against the current dev?

raintonr’s picture

Patch? For a one line change? :(

michaek’s picture

Yes, that's what I was asking. There are a lot of open issues on this module, and I don't have a lot of time, so I'll generally try to encourage people to get issues as close to committable as possible. If rolling a patch is prohibitive for you, can you check that the line number hasn't changed in the current dev release?

jon pugh’s picture

StatusFileSize
new1.51 KB

Patch attached, $params is now optional for $twitter->get_request_token();

dabblela’s picture

+1 for this change, but having trouble applying the patch:

Hunk #2 FAILED at 314.

Trying against 3.0beta2, but also tried against -dev.

univate’s picture

Version: 6.x-3.0-beta2 » 7.x-3.x-dev
Status: Needs review » Reviewed & tested by the community

Not sure where the main focus is on this module, but assuming development focus is on Drupal 7 I can confirm the the patch in #9 applies and works as required on the current 7.x-3.x-dev

univate’s picture

StatusFileSize
new1.55 KB

Just re-rolling this patch in the correct git -p1 format

justindodge’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new2.39 KB

Hi guys - I think this is an excellent functional enhancement for the twitter connect feature as well.

I was simply wanting to have mydomain.com and www.mydomain.com work with the twitter_signin.module, so I added your logic to the token generation there, and it works like a charm.

Here's the patch from #12 but with the sign in bit added.

pedrosp’s picture

Any chance to have a similar patch for 6x ?
Thanks

Pedro Lozano’s picture

The last patch works pretty well for me.

+1 to adding this functionality.

13rac1’s picture

Version: 7.x-3.x-dev » 7.x-5.x-dev

Patch needs updating for 7.x-5.x-dev. Does not apply anymore.

$ git apply twitter-oauth-callback-940060-13.patch 
twitter-oauth-callback-940060-13.patch:57: trailing whitespace.
  
twitter-oauth-callback-940060-13.patch:61: trailing whitespace.
  
error: patch failed: twitter.lib.php:331
error: twitter.lib.php: patch does not apply
error: patch failed: twitter.pages.inc:290
error: twitter.pages.inc: patch does not apply
error: patch failed: twitter_signin/twitter_signin.module:81
damienmckenna’s picture

Issue summary: View changes
Status: Needs review » Needs work

Triggering the testbot.

damienmckenna’s picture

Status: Needs work » Needs review

Triggering the testbot.

damienmckenna’s picture

StatusFileSize
new2.92 KB

Rerolled, though untested.

damienmckenna’s picture

StatusFileSize
new3.49 KB

Fixed a bug in twitter_oauth_callback_form_validate() with an undefined $token variable.

The last submitted patch, 9: twitter-oauth-callback-940060.patch, failed testing.

The last submitted patch, 12: 940060-12.patch, failed testing.

The last submitted patch, 13: twitter-oauth-callback-940060-13.patch, failed testing.

The last submitted patch, 19: twitter-n940060-19.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 20: twitter-n940060-20.patch, failed testing.

The last submitted patch, 19: twitter-n940060-19.patch, failed testing.

The last submitted patch, 20: twitter-n940060-20.patch, failed testing.

damienmckenna’s picture

Status: Needs work » Needs review
StatusFileSize
new2.8 KB

Rerolled.

damienmckenna’s picture

StatusFileSize
new2.89 KB

Rerolled.

damienmckenna’s picture

Version: 7.x-5.x-dev » 7.x-6.x-dev
StatusFileSize
new2.89 KB

Ported to 7.x-6.x.

Status: Needs review » Needs work

The last submitted patch, 31: twitter-n940060-31-7.x-6.x.patch, failed testing.

damienmckenna’s picture

Version: 7.x-6.x-dev » 6.x-5.x-dev
Status: Needs work » Needs review
StatusFileSize
new3.14 KB

Ported to 6.x-5.x.

damienmckenna’s picture

Version: 6.x-5.x-dev » 7.x-6.x-dev
StatusFileSize
new3.07 KB

Forgot that the callback URL was updated to be loaded from a variable. This is for 7.x-6.x.

damienmckenna’s picture

Version: 7.x-6.x-dev » 7.x-5.x-dev
StatusFileSize
new2.98 KB

Ported to 7.x-5.x.

The last submitted patch, 33: twitter-n940060-32-6.x-5.x.patch, failed testing.

The last submitted patch, 34: twitter-n940060-34-7.x-6.x.patch, failed testing.

damienmckenna’s picture

Status: Needs review » Fixed

Committed. Thanks all!

  • DamienMcKenna committed cec6397 on 6.x-5.x
    Issue #940060 by Jon Pugh, univate, justondoge, DamienMcKenna: Pass the...

  • DamienMcKenna committed b245cd4 on
    Issue #940060 by Jon Pugh, univate, justondoge, DamienMcKenna: Pass the...

  • DamienMcKenna committed 38f249a on 7.x-6.x
    Issue #940060 by Jon Pugh, univate, justondoge, DamienMcKenna: Pass the...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.