Local PC date and time affects server and return error 401


#1

Hi,

I developed a twitter app which allows user to connect their account to my site and start tweeting, sharing etc… One day when i was testing the app in my localhost i got error 401. When i checked twitter discussion forums i found that wrong date and time will cause this issue and fixed it. My PC got issues with CMOS battery so frequently my PC date and time is shown wrong.

Again a weird experience happened today, when i logged in to my site in server i got error 401 and lost all my twitter data stored in my site, the worst thing is all my clients who got connected to my app too lost their data. I faced a very hard time and many issues with my clients. Then i again reset date time in my local PC and restarted, Now the app in server works fine. this is totally weird, i dont understand how my PC date time affects Server API request to twitter?

I have many clients who use my app, i cannot expect everyone of them to use proper PC or laptop with proper date and time. I need help to handle this error 401 in my server and save all client’s data.

Looking forward for a solution.

Thanks


#2

Hi Karthikeyan,

Its nice to see your blog, I too need this kind of functionality in our application web site, but its in liferay portal with Java. So can you please share your code or steps to do this. Even I have tried it by searching in Google, but I could not able to find the proper plugin which supporting with Java application.

Please share your thoughts or inputs, awaiting for your reply.

Regards
Chandra


#3

Hi,

I am not aware of Java coding, this might help.

Thanks


#4

Thanks Karthikeyan for you reply.

Regards


#5

OAuth 1.0A is an authentication process that involves clock times in the signatures. We require pretty close adherence to Twitter’s server clocks.

If you can’t trust the clock in the environment your software runs, then you’ll need to adjust your timestamps to accomodate. When you make any request to api.twitter.com, you receive a HTTP header called “Date” – it tells you what the system time is on Twitter’s servers. Once you’ve determined the remote system time, compare it to your local time and determine the offset, then generate timestamps based on that offset.

Some folks issue a simple HTTP HEAD request to an api.twitter.com endpoint to determine the current time before starting a session.