mogya / oauth-adapter

Fork from http://code.google.com/p/oauth-adapter/
23 stars 10 forks source link

getRequestToken method fails to return proper URL to load #1

Closed stereoket closed 13 years ago

stereoket commented 13 years ago

compared to the original adapter - I get the following error on ios:

[WARN] Exception in event callback. {
expressionBeginOffset = 8365;
expressionCaretOffset = 8373;
expressionEndOffset = 8379;
line = 222;
message = "Result of expression 'callback' [undefined] is not a function.";
name = TypeError;
sourceId = 226570384;
sourceURL = "file://localhost/oauth_adapter.js";
}

If I use the original code for this method, the oAuth window loads. I can confirm that the token and token_secret are being returned to the app, it just doesn't pass the return value to the URL paramter - something to do with the return callback(text);

Here i the method that is buggy:

 // requests a requet token with the given Url
this.getRequestToken = function(pUrl, callback){
    accessor.tokenSecret = '';
    var message = this.createMessage(pUrl);
    OAuth.setTimestampAndNonce(message);
    OAuth.SignatureMethod.sign(message, accessor);

    var client = createHttpClient();
    client.open('POST', pUrl);
    client.send(OAuth.getParameterMap(message.parameters), function (http){
      var text = http.responseText;
      Ti.API.debug('request token got the following response: ' + text);

      var responseParams = OAuth.getParameterMap(text);
      requestToken = responseParams.oauth_token;
      requestTokenSecret = responseParams.oauth_token_secret;
      return callback(text);

    });
};
mogya commented 13 years ago

Unfortunately, this oauthadapter have some incompatibility from David’s oauth adapter. See readme or http://mogya.blog.com/2011/01/18/re-twitter-oauth-implementation-for-titanium-mobile/

If you mentioned about another point, please write code to reproduce the issue.

stereoket commented 13 years ago

The first problem I get when using your adapter (inside Titanium Developer and iOS simulator) is:

1) WebView for twitter oauth screen shows "Page does not exist" - as its not sending the oauth parameters in the URL request. Perhaps I need to take some screenshots.

stereoket commented 13 years ago

What seems to happen is that the simulator crashes when the destroyAuthorizeUI() method is called.

When loaded onto a device the screen stays on the page where you can see the PIN code, but the simulator crashes every time.

this is what the debug screen in Titanium shows.

https://gist.github.com/836141

mogya commented 13 years ago

I've seen that issue with 'Browser' type application setting, Check you're using 'client' application type on twitter application settings (https://developer.twitter.com/apps/ ).

stereoket commented 13 years ago

I'm making some changes so that it works across Android & iOS - I will push updates in my fork. I did check that it was set ti 'Client' - At the moment , I'm just dealing with Android webview and trying to get the pin retrieval working.

mogya commented 13 years ago

Sounds great! I'm looking forward your push.

stereoket commented 13 years ago

I will be pushing it soon. So many versions of this adapter out there now!

I have code pin code and auth tokens saving on both iOS and Android, but now have an error when sending a POST to twitter. I keep getting:

error = "Error Domain=ASIHTTPRequestErrorDomain Code=3 \"Authentication needed\" UserInfo=0x6f4bec0 {NSLocalizedDescription=Authentication needed}"; source = "[object TiNetworkClient]"; type = error;

Whereas GET requests work fine. Slowly getting there.

stereoket commented 13 years ago

I've pushed a version that works on android in my repo now, there are only a couple of minor UX issues. I would like to tidy it up a lot after I get my alpha app test completed. Cheers.