Android OAuth Invalid/Expired Token

I’ve been going over Marko Gargenta’s Learning Android book, published by O’Reilly Media; in it he goes through the creation of a basic Twitter app.  After struggling through the first example, I discovered two things:

  1. The examples in the book was using deprecated calls in the JTwitter library.  Twitter had moved away from simple authentication and now prefers OAuth
  2. The android emulator was running super slow

I was able to resolve the first issue by doing a bit of independent research into how OAuth works in Android.  I also switched over to the Twitter4J library as well.  I’ll make a post about that later as it was a bit of a discovery process to get it all working.

To address the speed issue, a Stack Overflow search gave me this useful post: Slow Android Emulator

Using those two bits, I managed to get things up and running at a decent speed.  Things were working great for a while until I started to get a mysterious Invalid/Expired Token exception whenever I tried to authenticate the application through OAuth calls.  After a bit of digging, I found out that the tokens that are issued via OAuth requests expire relatively shortly.  The problem was, I was requesting these tokens immediately!

After stepping back for a bit, I realized that the Android emulator snapshot that I was using to speed up the boot-up process was conflicting with the OAuth token acquisition and verification.  So the simple fix was to turn off Snapshots and use the Android AVD normally.

Posted in Java, Tech | Tagged , , , , , , , , , | Leave a comment

Android SDK Update: A folder failed to be renamed or moved

I recently decided to jump into some Android development in my spare time.  Using Eclipse as my IDE, I already have most of the Android SDK environment set up on my machine.  Using the Android SKD and AVD Manager, I decided to install a year’s worth of SDK updates.

Unfortunately, a few minutes after the update process started I ran into the error which said (in general terms): Failed to rename directory C:\Program Files\android-sdk-windows

The general advice to resolve this issue was to turn off/disable any Anti-Virus software running on your system. Unfortunately, this didn’t do much to resolve the issue.

In order to resolve this issue and get the updates going again, you have to close Eclipse and re-run it using Administrator privileges. This will give Eclipse and the associated Update tool enough privileges to move and rename things as it pleases

Posted in Java, Tech | Tagged , , , , , , , | Leave a comment

Using nmap on Windows to do a reverse DHCP lookup on a VPN

I’ll be traveling to London, UK for PLASA 2011 for two weeks in September.  This is a big problem for me because that means I’ll miss an entire Sprint’s worth of development at the Toronto office.  I wanted to keep apprised on developments through e-mail, the internal office websites and JIRA; so I asked for VPN access.

However, the VPN was configured in such a way that I was not able to directly access machines through their DHCP assigned names.  This is a huge problem for me because I relied on these names to access internal office sites.  So is one to do?  well, use nmap

nmap is a versatile network analysis tool. While it’s claim to fame is through the hacking community, it has multiple legitimate uses, like doing reverse DHCP lookups on your VPN. On my Windows 7 machine, I installed the latest windows binaries of nmap here: http://nmap.org/download.html

Once installed, I ran zenmap and executed the following command:

nmap -SL -Pn -R <target range>

This scanned the entire <target range> and spits out their DHCP names (if available)

Posted in Tech, Win32 | Tagged , , , , , , , | Leave a comment

Subversion Edge on Python 2.7

In a previous post, I mentioned that CollabNet’s Subversion Edge uses the Python 2.5 package by default.  If your current computer has applications which rely on a version that is not Python2.5,  you may experience a bunch of execution errors on runtime .  I described a solution to this problem in a previous post “No module named pkg_resources”

If you followed the procedure outlined in the previous post, you’ll find that the fix to the Python version-ing issue will break Subversion Edge.  The release build of Subversion edge is only compatible with Python 2.5 and not Python 2.7.  In order to make Subversion Edge run on Python 2.7, you will need to download the latest nightly build here: http://pkg.collab.net/build/windows/

Download the latest build of Subversion Edge, unzip the file and copy it into your csvn folder (typically located in C:\csvn). Overwrite all of your files and restart your computer. Once the process is complete, you’ll find that Subversion Edge is back up and running.

Posted in Tech | Tagged , , , , , , | Leave a comment

No module named pkg_resources

At work I am constantly exploring and testing new collaboration platforms on my desktop computer.  Currently, I have WordPress, Trac, and JIRA installed and running on my local network.  As a team, we experiment with these products and evaluate their usefulness on a day-to-day basis.  I recently installed Collabnet’s Subversion EDGE onto my machine so that I could apply version control to some of my product management documents.

That turned out to be a bad idea.

Immediately after restarting I found that my Trac install would not run.  After trying to restart the service, I tried to execute the tracd command manually in the command line.  Upon doing so, I received this error:

No module named pkg_resources

I tried executing a few basic commands such as easy_install and encountered the same problem. Finally, after running python through the command line, I quickly discovered the problem: my default python was set to 2.5 for some reason.

It turns out that Subversion Edge installs its own version of Python in C:\csvn\Python25. In order to get trac back up and running again, I had to:

  1. Remove C:\csvn\Python25 from my PATH variable
  2. Modify my PYTHONPATH variable to point back to the proper python C:\Python27

It would’ve been nice if the Subversion Edge installer warned you of this first. Fortunately, Google was my friend and I was able to find the solution quite quickly.

Posted in Tech | Tagged , , , , , , , , | 1 Comment