Google Authenticator not work on my website (https) (v2022)

Hi,
I enabled Google Authenticator (2FA). I can login to the system on my local server and Google Authenticator generated code works fine. However, I can’t login on my website and I receive an error. (CODE is not correct).
How to fix the issue?Thanks

Which version are you using? If v2023, I cannot reproduce. Make sure you have selected the User Profile field, see Two Factor Authentication. You may also enable Debug and log errors on your server.

Hi,
I tried using 2FA for my website many times. it works on my local server (Xampp). However, 2FA does not work for my website. I enabled the debug mode. no any error related to google authenticator displayed.
What’s the problem?
Thanks

Are you sure you have enable all the settings for debug, espeically those in php.ini? You may check the settings mentioned in the docs. Check both log files by PHPMaker and PHP processor.

Hi,
I checked the issue again. No any log for this problem.
Google Authenticator (2FA) works in my local server(http) but does NOT work on my website(https)?! Is there any configuration that I need to edit ?
The Error Message on my website: Two factor authentication verification failed
Thanks

  1. Press F12 in your browser and go to the Console panel to check for JavaScript error
  2. Check HTTP response
  3. If you added the feature in the later stage of development, make sure you have uploaded the lateset “vendor” folder to your site again.

Hi,
I tested again:Request URL: https://mysite.xxx/api/2fa/verify/830500?csrf_name=csrf63673e75d3799&csrf_value=Fg%2B6yKUykLFJme8iEiiVsEJ6oxefG7O3miokX7%2BBu0AnaYiunAT1gCug3RB3TvaFckPAL6p%2Bh4KuGRZu3OSLIQ%3D%3D
Request Method: GET
Status Code: 200
Remote Address: 45.149.76.14:443
Referrer Policy: strict-origin-when-cross-origin
Response Header:
access-control-allow-credentials: true
access-control-allow-headers: X-Requested-With, Origin, X-Authorization
access-control-allow-methods: GET, POST, PUT, PATCH, DELETE, OPTIONS
access-control-allow-origin: *
cache-control: no-store, no-cache, must-revalidate
content-type: application/json; charset=utf-8
date: Sun, 06 Nov 2022 05:11:35 GMT
expires: Thu, 19 Nov 1981 08:52:00 GMT
pragma: no-cache
server: Apache/2
set-cookie: PHPSESSID=secc7hun4ltj0pj44ffb5o89d4; path=/; Secure; HttpOnly; SameSite=Lax;
vary: Accept-Encoding,User-Agent
x-content-encoding-over-network: gzip
x-powered-by: PHP/8.1.8Unfortunately it does NOT work.{“success”:false,“version”:“18.12.0”}Because of 2FA works with local host it seems the problem is related to HOST address or https configurations.any idea?Thanks

So the error is on the server side.Make sure you have enable all the settings for debug, espeically those in php.ini. You may check the settings mentioned in the docs.

For the php.ini, you should enable:

  • error_reporting (int) - set it to E_ALL
  • display_errors (string) - set it to On
  • log_errors (bool) - set it to On
  • error_log (string) - set it to a log file on your server, e.g. “my/path/php_errors.log” (change “my/path” to your real path), the file should be writable by the web server’s user. Note that this is error log by the php.exe, NOT same as log files (by PHP scripts) above.

Then test your site again, check BOTH log files by PHPMaker and PHP processor.If the authentication does not pass, there must be some error.

Hi,
I tried to enable 2FA for directadmin of my site. When testing the code I received the different time/date error with my server. I configured my server date. after that 2FA works fine.
Thanks