Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug between 0.7 and 0.8 #4

Open
lunika opened this issue May 4, 2011 · 35 comments
Open

bug between 0.7 and 0.8 #4

lunika opened this issue May 4, 2011 · 35 comments

Comments

@lunika
Copy link

lunika commented May 4, 2011

A bug is introducing in version 0.8 that is not present in 0.7

After calling authorize, you cannot send a tweet. If you kill the Application, you can send tweet.

@jpurcell
Copy link
Owner

jpurcell commented May 4, 2011

That's bad news. I'm looking into it. Can you tell me which platform and SDK version and what titanium version you are using?

@lunika
Copy link
Author

lunika commented May 4, 2011

SDK titanium : 1.6.2
SDK iphone : 4.3

@jpurcell
Copy link
Owner

jpurcell commented May 4, 2011

On iPhone 4.3 and Ti Mobile 1.2.2 I'm not experiencing issues.

@lunika
Copy link
Author

lunika commented May 4, 2011

I use The Ti developper 1.2.2 too, but what is the version of the titanium mobile SDK?

The last stable version is : 1.6.2 and developping version : 1.7.0

@jpurcell
Copy link
Owner

jpurcell commented May 4, 2011

Oh, yea, sorry--I keep doing that. I'm using 1.6.2.

Are you on iPhone or Android?

@lunika
Copy link
Author

lunika commented May 4, 2011

I'm on iphone but on the simulator, I don't have the device.

@jpurcell
Copy link
Owner

jpurcell commented May 4, 2011

Ok, that's fine--I'm testing in simulator as well. I'm not experiencing this issue. Can you perhaps use the debug version and post your output? Be sure to remove tokens and such.

@lunika
Copy link
Author

lunika commented May 4, 2011

[INFO] ----- Opening Tweet UI -----
[DEBUG] fn-tweet: authorized is: true
[DEBUG] fn-tweet: we are authorized, initiate tweet sequence
[DEBUG] fn-api: callback sent is undefined
[DEBUG] fn-api: force authorization is true
[INFO] ----- Initializing API Request Sequence -----
[DEBUG] access_token is xxx typof: string
[DEBUG] fn-api: accessor is {"consumerSecret":"xxx","tokenSecret":"xxx"}
[DEBUG] the API request message: {"action":"http://api.twitter.com/1/statuses/update.json","method":"POST","parameters":[["status","Some default text. azdazd"],["oauth_token","xxx"],["oauth_consumer_key","xxx"],["oauth_signature_method","HMAC-SHA1"],["oauth_timestamp","1304516745"],["oauth_nonce","duQxKUT1iCAcJF0EkUHQc7ylTnDHMzUaGHbeWCTtFZ"],["oauth_version","1.0"],["oauth_signature","Yh1fRlsaQsKc2WxxdzOz/om1qtQ="]]}
[DEBUG] api url: http://api.twitter.com/1/statuses/update.json?status=Some%20default%20text.%20azdazd
[DEBUG] fn-api: auth is OAuth status="Some%20default%20text.%20azdazd",oauth_token="xxxx",oauth_consumer_key="xxxx",oauth_signature_method="HMAC-SHA1",oauth_timestamp="1304516745",oauth_nonce="duQxKUT1iCAcJF0EkUHQc7ylTnDHMzUaGHbeWCTtFZ",oauth_version="1.0",oauth_signature="Yh1fRlsaQsKc2WxxdzOz/om1qtQ%3D"
[INFO] var_dump: error (object):Error Domain=ASIHTTPRequestErrorDomain Code=3 "Authentication needed" UserInfo=0x6e07bf0 {NSLocalizedDescription=Authentication needed}
[DEBUG] The API XHR request has failed! Status=4 and var_dump of e is undefined

@jpurcell
Copy link
Owner

jpurcell commented May 4, 2011

!!!!
I know what the issue is, just a sec and let me verify.

@jpurcell
Copy link
Owner

jpurcell commented May 4, 2011

Hmm... maybe not. Let me do a fresh build and see if I get any errors.

@jpurcell
Copy link
Owner

jpurcell commented May 4, 2011

Ok, I'm not exactly sure how to interpret what's happening. The last two lines of output are coming from line 548 in debug js. It looks like the error is "Authentication needed", but I don't understand that. Line 548 will only fire if the call fails to get a response from Twitter, so that authentication error can't come from Twitter. Are you behind a proxy or firewall or something that's blocking the call? What are your thoughts?

@lunika
Copy link
Author

lunika commented May 4, 2011

I'm not behind a proxy.

I test with 0.7 version, I don't have the error message, the winTW close but the tweet never arrive on twitter website. Always, if i kill the application, the tweet function work fine.

Thx for your help and sorry for my english :-)

@lunika
Copy link
Author

lunika commented May 4, 2011

what i'm doing is very simple :

twitter.addEventListener('click',function(e){
// BH.deauthorize();

if(BH.authorized() == false){
    BH.authorize(function(e){
        if(e === true){
            BH.tweet('Some default text.');
        }
    });
}
else{
    BH.tweet('Some default text.');
}

});

the twitter object is a button create with Ti.UI.createButton

@jpurcell
Copy link
Owner

jpurcell commented May 4, 2011

Ok, sorry I couldn't be of more help. If anyone else is having this issue please keep us updated! Cheers!

@jpurcell
Copy link
Owner

jpurcell commented May 4, 2011

Hahaha, it looks like you commented before I did! I didn't see it.

Ok, lunika, something to keep in mind. The API function has built in an authorization checker, see line 463 of the debug version. So, that code you posted could be condensed to:

BH.tweet('Some default text.');

And it, conceptually, does the same thing. Will this suffice for you?

Now, what you are trying to do IS supposed to work, so this really is a bug. I will put this in the works to be tested and fixed by v0.9.

@lunika
Copy link
Author

lunika commented May 4, 2011

I change with you proposition, only : BH.tweet('Some default text.');

It does the same thing and the same error.

this is the Json response of twitter :

response: {"request":"/1/statuses/update.json?status=Some%2520default%2520text.","error":"Could not authenticate you."}

@jpurcell
Copy link
Owner

jpurcell commented May 4, 2011

Hmmm... I'm at a loss here. Can you verify that: (1) when you initialized BirdHouse you have the correct API keys like such:

var BH = new BirdHouse({
    consumer_key: "yourappsconsumerkey",
    consumer_secret: "yourappsconsumersecretwhichislonger",
    callback_url: "http://yourappscallbackurl.com";
});

and (2) that in your application's settings the application's type is "Browser" (not "Client") and the callback url is set?

Also, can you post as much of the output as you can?

@lunika
Copy link
Author

lunika commented May 4, 2011

(1) : I initialized BirdHouse like your exemple in the BirdHouseApp with the right parameters

(2)
Application type : Browser
Default Access type: Read&Write
Callback Url is set

I send the output later

@jpurcell
Copy link
Owner

jpurcell commented May 4, 2011

Yes, but here's the thing:

response: {"request":"/1/statuses/update.json?status=Some%2520default%2520text.","error":"Could not authenticate you."}

Should be coming from a different context than:

[INFO] var_dump: error (object):Error Domain=ASIHTTPRequestErrorDomain Code=3 "Authentication needed" UserInfo=0x6e07bf0 {NSLocalizedDescription=Authentication needed}
[DEBUG] The API XHR request has failed! Status=4 and var_dump of e is undefined

if indeed that response is coming from Twitter, because, as mentioned, the latter (the XHR request failed) is an error thrown by Titanium.

Did I explain that correctly? So, I'm wanting to see the most recent output, the "Could not authenticate you." error, in context to help me understand what's going on, since I can't reproduce the error.

@jpurcell
Copy link
Owner

Ok, lunika, just this week I had incorrectly typed the consumer keys and received errors that are what I think identical to yours:

[INFO] var_dump: error (object):Error Domain=ASIHTTPRequestErrorDomain Code=3 "Authentication needed" UserInfo=0x6a377f0 {NSLocalizedDescription=Authentication needed}
[DEBUG] The API XHR request has failed! Status=4 and var_dump of e is undefined
[INFO] response: Failed to validate oauth signature and token

Can you first double check and make sure your tokens are correct? Next, if that does not fix the issue, can you please give the full output for context to the error?

@lunika
Copy link
Author

lunika commented May 11, 2011

My consumer_key et consumer_secret are good.

I can send tweet but not after calling authorize function.

This is what I do :

  • I launch the application
  • I click 'authorize' button, the webview appears and I authorize the application.
  • The callback alerts me that I'm authorized.
  • I click 'send tweet', i write something and click 'Tweet'
  • the callback alerts me that 'your tweet was not send :('
  • I quit the Application
  • I Kill the application
  • I relaunch the application
  • Now i can send tweet

What information do you want?

@lunika
Copy link
Author

lunika commented May 11, 2011

can I have your mail to send you all the output?

@jpurcell
Copy link
Owner

lunika, I forgot you are in a different time zone. I followed exactly as you had done (I even tried other functions) and it worked. Yea, if you can authorize then your consumer tokens are certainly correct. It would help to have the output--my hope is to compare your output with mine to find what the issue is. My email is [email protected] and please remove/modify your consumer tokens from the output. I do hope we can find the issue.

@ghost
Copy link

ghost commented May 27, 2011

Hi guys, I'm also having problems. Titanium Studio RC1.0, Titanium SDK 1.6.2, iPhone 4 simulator.

Basically I can use the tweet() method which displays the Twitter login page. I can log in and it briefly displays a PIN in a large font before the view closes. The alert message "Your tweet was not sent :(". This happens on your test app I just downloaded this afternoon. Output from my debug window shows the following:

[DEBUG] fn-get_request_token: callback is undefined

[DEBUG] url is going to: http://api.twitter.com/oauth/authorize?oauth_token=XXXXXXXX

[INFO] 1: 

[INFO] 2: 

[INFO] 3: Twitter / Authorize an application

[INFO] 4: http://api.twitter.com/oauth/authorize?oauth_token=XXXXXXXX

[INFO] iAds have finished loading: load

[INFO] 1: 

[INFO] 2: http://api.twitter.com/oauth/authorize?oauth_token=XXXXXXXX

[INFO] 3: Twitter / Authorize an application

[INFO] 4: https://api.twitter.com/oauth/authorize

[INFO] ============== loads 2 ==============

[INFO] ====================check status

[INFO] ----ACCESS DENIED!!!!----

[DEBUG] fn-tweet: after asking for authorization, we didn't authorize, so we can't send the tweet.

[INFO] CALLBACK 0-false

My Twitter credentials are definitely correct because I get a message from Twitter briefly telling me that the app has been authorised and that the PIN gets displayed.

Like I say, it doesn't work for me with the test app either.

The code I used was in my app was:

var BH = new BirdHouse({
   consumer_key: "xxx",
   consumer_secret: "xxxxxxxxxxxxxx",
   show_login_toolbar: true
   // ,callback_url: "http://yourappsEXACTcallbackurl.com"
});

var twitterAlertDialog = Ti.UI.createAlertDialog({
    title: 'Message from Twitter',
    buttonNames: ['OK']
});

// tweet content
var tweet = 'Test tweet';


BH.tweet(tweet, function(resp){
    if (resp===true) {
        twitterAlertDialog.message = 'Your tweet was sent successfully';
    } else {
        twitterAlertDialog.message = 'Your tweet could not be sent';
    }
    twitterAlertDialog.show();
});

Any ideas what could be going wrong? It seems to stumble at the final hurdle.

Thanks in advance.

@jpurcell
Copy link
Owner

@guavadesign, I see that the second URL does not have the auth token, which means when Twitter forwards on it does not see the token in the URL and the app thinks it failed:

[INFO] 4: http://api.twitter.com/oauth/authorize?oauth_token=XXXXXXXX
...
[INFO] 4: https://api.twitter.com/oauth/authorize

In the latest version (0.9) I had hoped this kind of issue would be fixed by adding the setTimeout(checkStatus,1000) on line 243 on birdhouse.js. Perhaps set the timeout to 3000 and see if it catches the token.

Currently, I do not have time to devote to looking into this, but when I get a chance to I will look into the get_request_verifier so that instead of looking in the url for the oauth_token as so:

var parts = (e.url).replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
params = params + m;

if (key=='oauth_verifier') {
cfg.request_verifier = value;
}
});

It will look for the specified callback_url link. So, something like:

if (webView.url==callback_url){
//look for keys in url
//if none found then who knows what happened
//if found go to next step (get auth tokens)
}

I'm sorry I can't be of more help. If anyone can implement either of these to avoid this issue please share!

@jpurcell
Copy link
Owner

jpurcell commented Jun 2, 2011

Can you see if this comment fixed anything:
#9 (comment)

There is a supposed issue with the window?

@rblalock
Copy link

Getting the same issue on iOS here. Still investigating....

@asgharali
Copy link

has anyone been able to fix this issue...

@asgharali
Copy link

can someone try changing http://api.twitter.com/1/statuses/update.json to https://api.twitter.com/1/statuses/update.json and see if that works... ? it did for me.

@primorisMGPN
Copy link

I tried, but no improvement,


Error Domain=ASIHTTPRequestErrorDomain Code=3 "Authentication needed" UserInfo=0x6955110 {NSLocalizedDescription=Authentication needed}

[DEBUG] The API XHR request has failed! Status=4 Error Domain=ASIHTTPRequestErrorDomain Code=3 "Authentication needed" UserInfo=0x6955110 {NSLocalizedDescription=Authentication needed} and var_dump of e is undefined

[INFO] Failed to send tweet. status=XXX

[INFO] fn-tweet: retval is false

Any other solutions...?

@asgharali
Copy link

These are the steps that i followed and it is working fine for me now...

  1. Not sending X-Requested-With header #1 (comment)

  2. Not sending X-Requested-With header #1 (comment)

  3. Making sure all requests have https rather than http in it..

  4. Also, in get_request_verifier - i have added force_login=true

    var url = "http://api.twitter.com/oauth/authorize?oauth_token=" + cfg.request_token + '&force_login=true';

  5. Also, when get_acess_token is called, i am setting the params in the header rather than sending it as url params (not sure if this really helped me.. but it works for now) -

api(url, 'POST', 'oauth_token=' + cfg.request_token + '&oauth_verifier=' + cfg.request_verifier, function(ret, resp) {
//processing here
}, false, false, true);

Let me know if there is anything i can do to help..

@andrewMuntyan
Copy link

I have the same problem as here #4 (comment) . All that has been proposed as a solution - does not work. Any ideas?

Windows7
Titanium SDK - 1.8.0.1
Android 2.1

Regards

@saqib-dareshani
Copy link

[INFO] var_dump: type (object):error

[DEBUG] The API XHR request has failed! Status=4 and var_dump of e is undefined

Does anybody know how to fix this issue. It started just recently (it was working fine before)!

@saqib-dareshani
Copy link

Crazily enough, the error happens with 1.8.0.1 and 1.8.1! It goes away with 1.7.5!!!

Guys try 1.7.5 if you are having issues!

@ghost
Copy link

ghost commented May 11, 2012

For me with titanium SDK 2.0 and xcode 4.3 works changing http for https
[INFO] 4: http://api.twitter.com/oauth/authorize?oauth_token=XXXXXXXX
...
[INFO] 4: https://api.twitter.com/oauth/authorize

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants