error solved…oh god!!! figured out that the timing on the server was the problem. My server went down few days back and the time on the server was 2 hrs behind. just got the time right and the unauthorized 401 error was solved. Thanks to the discussion forums on Twitter