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

Thought this change would be helpful #6

Closed
wants to merge 1 commit into from
Closed

Thought this change would be helpful #6

wants to merge 1 commit into from

Conversation

bnvk
Copy link

@bnvk bnvk commented Mar 29, 2011

Hi Elliott,

The change is regarding the "authenticate" url vs. the "authorize" url which is the current method you have implemented. While using the later works, if a user has already "authed" in their account each time they are prompted to "Allow" twitter access... when using Twitter connect for signin this is an nuisance and detracts from the user experience. Hopefully you'll agree and this change is helpful

Cheers, BN

@cdevroe
Copy link

cdevroe commented Apr 13, 2011

+1

@rayfranco
Copy link

Hi brennannovak, this pull request was already made earlier there RayFranco@eef8b68e992635e72b1e464c0fb0e212b8219318
The discussion is still on, maybe you could help, as it doesn't work for everybody that have applied the patch.
Cheers.

@bnvk
Copy link
Author

bnvk commented Apr 22, 2011

In what way does it not work? I've used this new URL for quite some time... even with Elliot's old Twitter library. Perhaps the problem is not in this library, but rather in your Twitter Side App settings... there is that checkbox that asks "Will you use this app for signing in?" that may be causing "http://api.twitter.com/oauth/authenticate" to not work properly...

@cdevroe
Copy link

cdevroe commented Apr 22, 2011

@brennannovak I don't see a setting on dev.twitter.com for "Will you use this app for signing in?" Is it somewhere else?

@bnvk
Copy link
Author

bnvk commented Apr 22, 2011

The thing I'm thinking of isn't in the dev section of the site, but rather in your actual "app" setting:

https://twitter.com/apps/new

Just above the Captcha it says "Use Twitter for login"

@cdevroe
Copy link

cdevroe commented Apr 22, 2011

@brennannovak Crap. There is no way to tell if my app has that selected or not. Weird.

@cdevroe
Copy link

cdevroe commented Apr 22, 2011

@brennannovak Do you think this might be why Twitter is replying with oauth_verifier instead of oauth_token_secret which makes the app not work? #2 (comment)

@carolinecblaker
Copy link

I don't see "Use Twitter for login" but rather "Read" vs "Read and Write" - Write would require auth. I have it set at "Read and Write" and I'm still experiencing this issue.

@cdevroe
Copy link

cdevroe commented Apr 25, 2011

@carolinecblacker The only place you will see it is when you're creating a new application not when you are editing the details of an existing one.

@carolinecblaker
Copy link

When going to a screen to register a new app, there is only Read vs Read and Write, and no "use Twitter for login" option.

https://dev.twitter.com/apps/new

@bnvk
Copy link
Author

bnvk commented Apr 25, 2011

Whoa. You're right Caroline... I've never created a new Twitter via that link... I still use

https://twitter.com/apps/new

Which does still have the "Use Twitter for login" option. Weird.

@cdevroe
Copy link

cdevroe commented Apr 25, 2011

@carolinecblaker @brennannovak @rayfranco I think the thing that boggles my mind the most, is why I never get oauth_token_secret back from Twitter. I get oauth_verifier which, based on my inspection of the code, is not used by this Library.

I've now moved everything to my staging server in hopes that it was a localhost cURL issue and I'm having the same exact issue. I'm logging every single thing that happens too. And as far as I can tell, this Library simply ignores the callback URL of /tweet_test/auth?oauth_token=WHATEVER&oauth_verifier=WHATEVER

It simply does not know that I'm logged in. :(

@carolinecblaker
Copy link

Okay okay okay I think I may have solved this:

Consider: http://dev.twitter.com/pages/auth#access-token

This authorization process actually falls short of an entire exchange that twitter requires for Authentication. I'm not sure when this was put in place, but clearly it was between the time that this was coded and now. Can you guess what it is? If you answered "Exchanging a request token for an access token" (As in the 401 error we are getting with the latest auth and tweet-test.) you are right.

There needs to be a POST exchange (detailed in the above link) at the endpoint:
https://api.twitter.com/oauth/access_token

Give a quick find search in tweet.php - it's non-existent.

Now, since I've given up an entire work day to get to this point - do one of y'all have enough nerd energy to code this puppy? I'm neither nerdy enough nor energetic enough.

Many thanks.

CCB

@bnvk
Copy link
Author

bnvk commented Apr 25, 2011

Hmmmm... I dunno what your issue is. Very weird. Feel free to play with my app that actually uses the Twitter auth signin (and creates new user account) located at http://github.com/socialigniter/twitter as part of my larger distributed social network platform located at http://social-igniter.com you can test the signup / login functionality there :)

@carolinecblaker
Copy link

Alternately, according to the above mentioned docs, this code appears to be confusing two different secret access strings - the "oauth_token_secret" and the "oauth_verifier" - the "oauth_token_secret" should be delivered by the API before the user is sent to authorize, at which point they get the "oauth_verifier" which is saved as a token as "access_secret" in the userdata.

The "oauth_token_secret," either by being lost or never requested or saved, is untraceable and is critical to getting the access token at the last step of the authentication.

@cdevroe
Copy link

cdevroe commented Apr 26, 2011

@brennannovak You've been holding out on us! Checking our socialigniter.

@cdevroe
Copy link

cdevroe commented Apr 26, 2011

@brennannovak Boy do I wish my code worked as well as yours. After a week I'm still not going to give up. Though I may write my own library.

@cdevroe
Copy link

cdevroe commented Apr 26, 2011

@carolinecblaker Are you sure the issue you've found is what is wrong? Somehow, and I'm not yet sure how, everyone else is able to use this Library except you and I.

@carolinecblaker
Copy link

This is true.

We're still finding a variety of idiosyncrasies with how Twitter registers apps and perhaps how they treat new apps vs existing apps in respect to oauth/basic auth. It would appear that now they are specifying a version of oauth to call in the url even through there is only one version at this time.

While it may not be wrong for everyone, I am certain that I am finding that the twitter oAuth errors are completely explained by the docs I am using. No secret token is saved as a result of the initial token request and in its place the oauth_verifier is saved as access_secret. They are needed separately to complete the third step of the Authorizaiton. So basically we're playing with four ingredients when we need five. I've written code on my version that saves this extra var and I look forward to cracking into this.

@cdevroe
Copy link

cdevroe commented Apr 26, 2011

I'm having a conversation with Twitter devs right now about this... I'll update this thread when a resolution comes to the fore. Suffice to say, this Library is following a slightly old OAuth spec and we may need to update it before it will work properly.

@carolinecblaker
Copy link

Wonderful. Can't wait to get this up and running.

@cdevroe
Copy link

cdevroe commented Apr 26, 2011

So, I got some excellent information from http://twitter.com/episod about exactly what is going on here. As we expected, this Library is not handling the OAuth requests properly anymore. The OAuth spec has changed and Twitter has been slowly, but consistently, tightening everything up and depreciating the old parts of the old spec.

As a result there needs to be some things changed/adjusted in this Library. Here are the notes Taylor gave me.

Make sure that all of your OAuth URLs are https://api.twitter.com/oauth/* (where * is the last part of the path to the OAuth endpoints).
Always pass an explicit oauth_callback parameter to the request_token step AND ONLY the request_token step. Even if you've stored a default callback_url on your application record, it's improper OAuth to not explicitly send it on the request_token step (this is where a lot of OAuth libraries start down the wrong path -- they'll either not send this explicitly or they'll send it on the authorize or authenticate step instead -- which is how it was done in early OAuth)
If you follow these steps, you'll always get an oauth_verifier back when your oauth_callback is executed (whether you used authenticate or authorize).
When you get the oauth_verifier in your callback, send it back along with the request token details in the access token step.

Armed with all of these tips I plan on updating my fork of this Library. However, I'm leaving tomorrow for a cod fishing trip and won't be able to begin coding this up until Friday at some point. If any of you need the updates to this Library before then feel free to take the above tips from Taylor and run with them.

As far as the new app registration URLs... only use the dev.* URL. The old one is both invalid and going away soon enough. The "Use Twitter for Login" option does nothing.

I will say that Twitter was incredibly responsive to this issue both through Twitter and email. Hats off to their team.

@carolinecblaker @rayfranco @brennannovak

@episod
Copy link

episod commented Apr 26, 2011

Hi folks,

I've prepared a commit that I believe will address the issue with oauth_verifiers -- I don't have the proper environment to test and I'm not a native CodeIgnite speaker, so forgive me if I cargo-culted your patterns wrong.

https://github.com/episod/codeigniter-twitter/commit/b10474f9c42e04ee25379f7b897c0181ff5c12b0

Before invoking your OAuth flows, I recommend using the $this->tweet->set_callback(site_url('YOUR_PATH/TO/OAUTH')) function call to explicitly set the oauth_callback, right before the request token step.

The only modifications my code here makes is to watch for the oauth_verifier when it comes to your callback step, and then to append the oauth_verifier as an OAuth parameter when it is present.

If this patch works for you, let me know!

@cdevroe
Copy link

cdevroe commented Apr 26, 2011

@episod First, thanks for even taking the time to go after this. Second, for whatever reason your Library commit goes to https://api.twitter.com/oauth/authorize?oauth_token= and says Woah there!

@cdevroe
Copy link

cdevroe commented Apr 26, 2011

@episod This is my controller: https://gist.github.com/f5bc3f0b18b66bdf61ee/7501bcb38d9bd147ce5e1c4a08d9b0c6f7c8093e And I do call set_callback()

@episod
Copy link

episod commented Apr 26, 2011

OK, don't hate me for this, but I reformatted my fork's version of the libraries/tweet.php file so I could work with it better -- I had made an incorrect diff earlier trying to preserve the original formatting of the file and it's much easier for me to work with it this way.

In this revision, I've re-remembered some of my rusty PHP and improved a little of this logic.

Your controller looks fine from what I can tell -- if you weren't passing an oauth_token value to the authorize page, that means the request token step may have failed or the value fell out of session or my code clobbered it somehow (perhaps because of a silent error). Before you retest, I recommend clearing out your session so you're starting from a clean slate.

If it still doesn't work for you, I'll add some logging in tomorrow and try to get it running on my machine -- it's likely something subtle that someone with a bit more familiarity may spot.

https://github.com/episod/codeigniter-twitter/commit/e6fb9abdc085854aebe68d225ac21e5361eae5cf

@cdevroe
Copy link

cdevroe commented Apr 28, 2011

@episod I'll be taking a look at this this morning. But even after clearing everything out I'm still getting the same issue. Hopefully I can find out what is going wrong now.

@cdevroe
Copy link

cdevroe commented Apr 28, 2011

@episod Since my controller already uses CodeIgniter's built-in logging thingy this is what I got back after running it with your latest commit.

ERROR - 2011-04-28 10:07:04 --> Severity: Notice --> Undefined variable: url /home/ownerswi/staging/application/libraries/tweet.php 544
DEBUG - 2011-04-28 10:07:04 --> Language file loaded: language/english/unit_test_lang.php
INFO - 2011-04-28 10:07:04 --> Not logged in.
ERROR - 2011-04-28 10:07:04 --> Severity: Notice --> Undefined variable: url /home/ownerswi/staging/application/libraries/tweet.php 544
ERROR - 2011-04-28 10:07:04 --> Severity: Notice --> Trying to get property of non-object /home/ownerswi/staging/application/libraries/tweet.php 204
ERROR - 2011-04-28 10:07:04 --> Severity: Notice --> Trying to get property of non-object /home/ownerswi/staging/application/libraries/tweet.php 204
ERROR - 2011-04-28 10:07:04 --> Severity: Notice --> Trying to get property of non-object /home/ownerswi/staging/application/libraries/tweet.php 488
INFO - 2011-04-28 10:07:04 --> The user has been sent to Twitter.
ERROR - 2011-04-28 10:07:04 --> Severity: Notice --> Undefined variable: url /home/ownerswi/staging/application/libraries/tweet.php 544

@episod
Copy link

episod commented Apr 28, 2011

Will try to look at this again today -- this is likely just my PHP being rusty.

@carolinecblaker
Copy link

I want to let everyone know that after hours and hours of combing through this along with the current dev docs I got Twitter to authorize my app and save the user's access token and preferences in the session data. I'll be posting a less-buggy finalized version when it's ready.

It looks nothing like the original.. :)

@cdevroe
Copy link

cdevroe commented May 3, 2011

@carolinecblaker Do share!

@carolinecblaker
Copy link

@cdevroe - Will do, just as soon as I get it to post a status update and clear some of the refresh-the-method bugs.

@robfe11
Copy link

robfe11 commented May 12, 2011

@carolinecblaker any luck?

@cdevroe
Copy link

cdevroe commented May 15, 2011

It looks like our contact at Twitter has also thrown in the towel on trying to fix this Library. The Facebook Library that Elliot has released has many issues as well, and so many have dropped them.

I've been able to add Facebook Connect to my application very easily and will be focusing on Twitter Auth integration in my next build. When I do this, I'll likely build my very own Library and release it. I hope. :)

@robfe11
Copy link

robfe11 commented May 17, 2011

@cdevroe I ended up using the twitter-async library, works great, just add those three files as includes in your controller or within a library:

http://www.jaisenmathai.com/articles/twitter-async-documentation.html

@carolinecblaker
Copy link

Hi guys - I've posted my changes.

Check out the readme and give it a try:

https://github.com/carolinecblaker/codeigniter-twitter/

@carolinecblaker
Copy link

I've just gotten through this to the point of no bugs - other than inability to auto-tweet -

What do you all think? Do you still need this library?

@bnvk
Copy link
Author

bnvk commented Jul 21, 2011

Yah post your version up somewhere for sure. I'd be curious to see whatcha did!

@carolinecblaker
Copy link

https://github.com/carolinecblaker/codeigniter-twitter

Please please please pick this apart and let's make it tweet! It's fully operational with GET'g and Auth'g

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

Successfully merging this pull request may close these issues.

6 participants