Implementing TOTP Two Factor Authentication for Google Authenticator with PHP & AJAX @HazardEdit
Implementing TOTP Two Factor Authentication for Google Authenticator with PHP & AJAX  @HazardEdit
Uploaded December 2017 | Updated September 2026, 3 weeks ago
What is TOTP?
TOTP is a short form for Time-based One-time Password (usually called Token) which is password that can only be used once and is only valid to be used in a defined time range. Usually TOTP generators generate new passwords every defined number of seconds or minutes.

What is Google Authenticator?
Google Authenticator is a TOTP/HOTP generator you can freely use for your software, app or website authentication.

How does it work?
A simplified explanation would be, both google authenticator app and your authentication program know the same secret key and can compute the same token for a certain range in time based on this secret key.
A more technical explanation can be read here: security.stackexchange.com/questions/35157/how-does-google-authenticator-work

Getting Started
To get started you will have to download the Google Authenticator app to your smartphone or tablet etc.
In this implementation example I will be using a PHP Framework by Michael Kliewe (PHPGangsta). From my point of view the framework is lightweight and just perfect for this example. I will not be changing the author’s initial code.
The author has stored the Framework on his github repo. Feel free to download in order to follow along. github.com/PHPGangsta/GoogleAuthenticator

#Social
Twitter: twitter.com/hazardedit
Facebook: facebook.com/hazardedit

#Messenger
Skype: hazardedit

Email: hazardbusiness@gmail.com
Implementing TOTP Two Factor Authentication for Google Authenticator with PHP & AJAXAfter Effects Tutorial: Triangle (▲) EffectHow to open big Text FilesChilled. Episode EditMy Professional Website Design HTML & CSS Part 11Game Hacking Menu in C++ with Navigation (Arrow Keys) TutorialSafest Login Form with Encryption & Decryption & Email Notification in Visual Basic Tutorial
HazardEdit |

Implementing TOTP Two Factor Authentication for Google Authenticator with PHP & AJAX

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER