tags:

views:

1445

answers:

2

I am having a problem with Twitter's oauth authentication and using a callback url.

I am coding in php and using the sample code referenced by the twitter wiki, http://github.com/abraham/twitteroauth

I got that code, and tried a simple test and it worked nicely. However I want to programatically specify the callback url, and the example did not support that.

So I quickly modified the getRequestToken() method to take in a parameter and now it looks like this:

function getRequestToken($params = array()) {
  $r = $this->oAuthRequest($this->requestTokenURL(), $params);
  $token = $this->oAuthParseResponse($r);
  $this->token = new OAuthConsumer($token['oauth_token'], $token['oauth_token_secret']);
  return $token;
}

and my call looks like this

$tok = $to->getRequestToken(array('oauth_callback' => 'http://127.0.0.1/twitter_prompt/index.php'));

This is the only change I made, and the redirect works like a charm, however I am getting an error when I then try and use my newly granted access to try and make a call. I get a "Could not authenticate you" error. Also the application never actually gets added to the users authorized connections.

Now I read the specs and I thought all I had to do was specify the parameter when getting the request token. Could someone a little more seasoned in oauth and twitter possibly give me a hand? Thank You

A: 

Twitter does not honor the oauth_callback parameter and will only use the one specified in the registered application settings.

It also doesn't allow for 127.0.0.1 or localhost names in that callback, so I've setup http://dev.twipler.com which is setup for 127.0.0.1 in DNS so you can safely use;

http://dev.twipler.com/twitter_prompt/index.php
Dead account
+1  A: 

@Ian, twitter now allows 127.0.0.1 and has made some other recent changes.

@jtymann, check my answer here and see if it helps

http://stackoverflow.com/questions/2940528/twitter-oauth-callback-parameter-being-ignored/3351724#3351724

GL

jingles

jsh

related questions