MyBB Community Forums

Full Version: oAuth can be a PITA
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am rewriting MyBBPublisher from scratch and adding modules for additional services. These services use OAuth but don't have a pre-made library/wrapper.

Luckily Twitter is a good set of libraries available, but Twitter also offers user Access Tokens and Access Token Secrets directly from their developer website when you are creating your app. No need to go through the trouble of generating them yourself.

However, Tumblr (and most other providers) does not offer the token/secret directly like Twitter does, so I have to make the calls to the API to get that data. This requires multiple calls to the ACP page since I don't want a separate page to process the callback and with this, I need to temporarily store the original request token so I can access it after the ACP is reloaded. I can't use PHP session or cookies as the headers are already sent so I have to hijack the $admin_sesssion to store the temp variables. The original request token is needed to obtain the verifier code and the final access tokens. Very frustrating at times.

I was able to modify the Twitter OAuth library I was using (credited of course) to work with Tumblr.

That all said, writing OAuth is a PITA and gets confusing at times, but I think I have it down now. So Tumblr support for MyBBPublisher is almost ready and next is LinkedIn.

After this bit of work, I might be able to make a Steam plugin (that one may be paid though) since it uses OAuth as well.

okay, sorry for the venting, but I am glad that I finally figured it out.
Wow, great news Pavemen. I have been reading about the Tumblr API so I am not surprised at you saying it was a bugger to deal with.

Thanks for taking the time on this great plugin.
At least you got it working! Better than not having it working yet Toungue
How right you are, OAuth sure is a massive PITA to deal with. I can obviously see why it works how it does but it really can get frustrating at times. That's why I usually just depend on external libraries (as you have done up till now) rather than trying to write stuff from scratch.
I need to talk to you about your request btw. Please head over to communityplugins to discuss at http://www.communityplugins.com/forum/sh...hp?tid=133

(2012-08-09, 10:15 PM)euantor Wrote: [ -> ]How right you are, OAuth sure is a massive PITA to deal with. I can obviously see why it works how it does but it really can get frustrating at times. That's why I usually just depend on external libraries (as you have done up till now) rather than trying to write stuff from scratch.

it is painfully obvious what is does in a general sense, but tracking it through the code sucks. i did not really write the library from scratch (my plugin yes, but not the library). I took a good twitter library and copied, renamed and changed the class name and URLs to the host. Then in myplugin I wrote the code to generate the app authentication, request tokens, access token exchange, etc.

Still a PITA at the time
Spent a couple days trying to deal with OAuth 2. Wasn't very pleased with existing libs or classes.

Read this:

http://hueniverse.com/2012/07/oauth-2-0-...d-to-hell/

I'm personally wanting a 2FA option for MyBB. I was actually getting somewhere when I broke my hand a couple months ago delaying all my current work.
interesting read, thanks for the link
Thanks for the link labrocca, sure looks like an interesting read judging by the introduction. Bookmarked.