{"id":18550283,"url":"https://github.com/xp-forge/google-authenticator","last_synced_at":"2026-02-10T20:32:24.374Z","repository":{"id":26369264,"uuid":"29818489","full_name":"xp-forge/google-authenticator","owner":"xp-forge","description":"Google authenticator (HOTP \u0026 TOTP)","archived":false,"fork":false,"pushed_at":"2025-02-16T10:47:23.000Z","size":86,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-09-21T04:49:54.941Z","etag":null,"topics":["hotp","mfa","rfc-4226","rfc-6238","totp","xp-framework"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xp-forge.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2015-01-25T15:24:27.000Z","updated_at":"2025-02-16T10:46:18.000Z","dependencies_parsed_at":"2024-03-01T21:32:25.869Z","dependency_job_id":"25abc3d1-df2b-4e77-8675-5c5c7f9f8020","html_url":"https://github.com/xp-forge/google-authenticator","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/xp-forge/google-authenticator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xp-forge%2Fgoogle-authenticator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xp-forge%2Fgoogle-authenticator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xp-forge%2Fgoogle-authenticator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xp-forge%2Fgoogle-authenticator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xp-forge","download_url":"https://codeload.github.com/xp-forge/google-authenticator/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xp-forge%2Fgoogle-authenticator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29314705,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-10T17:48:59.043Z","status":"ssl_error","status_checked_at":"2026-02-10T17:45:37.240Z","response_time":65,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hotp","mfa","rfc-4226","rfc-6238","totp","xp-framework"],"created_at":"2024-11-06T21:04:05.863Z","updated_at":"2026-02-10T20:32:24.358Z","avatar_url":"https://github.com/xp-forge.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Google authenticator\n====================\n\n[![Build status on GitHub](https://github.com/xp-forge/google-authenticator/workflows/Tests/badge.svg)](https://github.com/xp-forge/google-authenticator/actions)\n[![XP Framework Module](https://raw.githubusercontent.com/xp-framework/web/master/static/xp-framework-badge.png)](https://github.com/xp-framework/core)\n[![BSD Licence](https://raw.githubusercontent.com/xp-framework/web/master/static/licence-bsd.png)](https://github.com/xp-framework/core/blob/master/LICENCE.md)\n[![Requires PHP 7.4+](https://raw.githubusercontent.com/xp-framework/web/master/static/php-7_4plus.svg)](http://php.net/)\n[![Supports PHP 8.0+](https://raw.githubusercontent.com/xp-framework/web/master/static/php-8_0plus.svg)](http://php.net/)\n[![Latest Stable Version](https://poser.pugx.org/xp-forge/google-authenticator/version.svg)](https://packagist.org/packages/xp-forge/google-authenticator)\n\nSupports one-time passwords accordings (HOTP \u0026 TOTP) according to [RFC 4226](http://tools.ietf.org/html/rfc4226) and [RFC 6238](http://tools.ietf.org/html/rfc6238).\n\nWorking with one-time passwords\n-------------------------------\nThe following shows the API for time-based one-time passwords (TOTP):\n\n```php\nuse com\\google\\authenticator\\{TimeBased, Tolerance};\nuse util\\Secret;\n\n$secret= new Secret('2BX6RYQ4MD5M46KP');\n$timebased= new TimeBased($secret);\n$time= time();\n\n// Get token for a given time\n$token= $timebased-\u003eat($time);\n$token= $timebased-\u003ecurrent();\n\n// Must match exactly\n$verified= $timebased-\u003everify($token, $time, Tolerance::$NONE);\n\n// Allows previous and next\n$verified= $timebased-\u003everify($token);\n$verified= $timebased-\u003everify($token, $time);\n$verified= $timebased-\u003everify($token, $time, Tolerance::$PREVIOUS_AND_NEXT);\n```\n\nThe following shows the API for counter-based one-time passwords (HOTP):\n\n```php\nuse com\\google\\authenticator\\{CounterBased, Tolerance};\nuse util\\Secret;\n\n$secret= new Secret('2BX6RYQ4MD5M46KP');\n$counterbased= new CounterBased($secret);\n$counter= 0;\n\n// Get token for a given counter\n$token= $counterbased-\u003eat($counter);\n\n// Must match exactly\n$verified= $counterbased-\u003everify($token, $counter, Tolerance::$NONE);\n\n// Allows previous and next\n$verified= $counterbased-\u003everify($token, $counter);\n$verified= $counterbased-\u003everify($token, $counter, Tolerance::$PREVIOUS_AND_NEXT);\n```\n\n*Note: We use util.Secret so that in case of exceptions, the secret will not appear in stack traces.*\n\nCreating secrets\n----------------\nAs an issuer of OTPs, you need to create random secrets in order to seed both client and server. Using the *provisioningUri()* method, you can fetch the URIs used to configure the clients.\n\n```php\nuse com\\google\\authenticator\\{CounterBased, TimeBased, Secrets};\n\n$random= Secrets::random();\n\n// HOTP, otpauth://hotp/{account}?secret={secret}\u0026counter={counter}\n$counterbased= new CounterBased($random);\n$uri= $counterbased-\u003eprovisioningUri($account);             // Start with counter= 0\n$uri= $counterbased-\u003eprovisioningUri($account, $initial);   // Start with counter= $initial\n\n// TOTP, otpauth://totp/{account}?secret={secret}\n$timebased= new TimeBased($random);\n$uri= $timebased-\u003eprovisioningUri($account);\n\n// Pass a map of string to append additional parameters\n$uri= $timebased-\u003eprovisioningUri($account, ['issuer' =\u003e 'ACME Co']);\n\n// Pass an array to namespace the account, yields \"ACME%20Co:user@example.com\"\n$uri= $timebased-\u003eprovisioningUri(['ACME Co', 'user@example.com']);\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxp-forge%2Fgoogle-authenticator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxp-forge%2Fgoogle-authenticator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxp-forge%2Fgoogle-authenticator/lists"}