Free Offer

Tuesday, 2 June 2015

Solved - Google Authenticator code not working with different time zone

I implemented Google authenticator in pydio (PHP software) and when tested things with google authenticator app (Android, Iphone), it worked only when both the pydio server timezone and My device timezone are same. As soon as timezones got out of sync things didn't work.
Now if you test same thing on gmail with 6 digit code from any timezone then it would work. To find its root cause I studied the NetworkSync functionality for Android Google Authenticator code and found that there for Sync it always fetches time from i.e. time in GMT and then sync the internal Google Authenticator App clock with that time and hence by one point of reference at Google server side and on Google Authenticator App i.e. GMT on both side the generated code will work irrespective of time zone. On Android Authenticator App you just have to sync time to be on safe side. No sync functionality found on Iphone App. I think it does same sync functionality automatically.
So after this study I just chnaged pydio time zone to GMT i.e. changed PHP timezone to GMT and now Google Authenticator is working irrespective of timezone. However if you face issue on Android Google Authenticator App then select SyncTime option in app to get your code working.

I hope this little information would help alot of people, specially those who are implementing Google Authenticator code validation on their end or using some software which implement server side Google code verification.

No comments: