{"id":16421855,"url":"https://github.com/aybruhm/django-sotp","last_synced_at":"2025-09-06T09:33:13.644Z","repository":{"id":38214054,"uuid":"495190268","full_name":"aybruhm/django-sotp","owner":"aybruhm","description":"Generate a secured base32 one time password to authenticate your user! 🔐","archived":false,"fork":false,"pushed_at":"2023-07-19T12:10:33.000Z","size":1144,"stargazers_count":36,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-29T21:11:48.620Z","etag":null,"topics":["authentication","django","one-time-password","otp","python"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"cc0-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aybruhm.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.txt","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2022-05-22T22:18:57.000Z","updated_at":"2024-08-08T20:45:16.000Z","dependencies_parsed_at":"2022-08-08T23:22:28.979Z","dependency_job_id":null,"html_url":"https://github.com/aybruhm/django-sotp","commit_stats":null,"previous_names":["israelabraham/django-sopt"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aybruhm%2Fdjango-sotp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aybruhm%2Fdjango-sotp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aybruhm%2Fdjango-sotp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aybruhm%2Fdjango-sotp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aybruhm","download_url":"https://codeload.github.com/aybruhm/django-sotp/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":232110851,"owners_count":18474030,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["authentication","django","one-time-password","otp","python"],"created_at":"2024-10-11T07:35:00.251Z","updated_at":"2025-01-01T18:18:16.608Z","avatar_url":"https://github.com/aybruhm.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Django SOTP 🔐\n\n![CI](https://github.com/israelabraham/django-sotp/actions/workflows/django.yml/badge.svg)\n[![PyPI version](https://badge.fury.io/py/django-sotp.svg)](https://badge.fury.io/py/django-sotp)\n\nGenerate a secured base32 one time password to authenticate your user!\n\n## Abstract 📑\n\nDjango SOTP does just two things, and does them really well.\n\n- One - it is stupidly secured and simple to integrate\n- Two - it clears out OTPs at the elapsed time\n\n## Installation ⏳\n\nInstalling django-sotp is very easy, you'll be using (I'd recommend you use a virtual environment, so you don't break your system) the command pip.\n\nHere's how to go about it:\n\n```bash\npip install django-sotp\n```\n\nNext is, adding the installed packages to your project:\n\n```python\nINSTALLED_APPS = [\n    ...\n    'sotp',\n]\n```\n\nSince `django-sotp` depends on a particular package to clear out the OTPs at the elapsed time. We'd have to include another package to our installed apps.\n\n```python\nINSTALLED_APPS = [\n    ...\n    'sotp',\n    'django_apscheduler', # added package ;-)\n]\n```\n\nNow you've done it, all you need to do is add the time which you want the generated OTPs to expire:\n\n```python\nSOTP_TIME_EXPIRATION = 5 # in minutes\n```\n\nYesss. Next is to make migrations and migrate to your database and you're good to go!\n\n```python\npython manage.py makemigrations \u0026\u0026 python manage.py migrate\n```\n\nCongratulations! You're all set! Let's jump right into how to start using it.\n\n## How-To Use 📝\n\nYou've got ```django-sotp``` installed and ready to use, here's how to start using it!\n\n- Step 1: Import the library to the file `(.py)` you want to use:\n\n ```python\n from sotp.services import GenerateSOTP\n ```\n\n- Step 2: Instantiate the class:\n\n```python\notp = GenerateSOTP()\n```\n\n- Step 3: Call the `generate_otp` logic (method) directly in the file, and pass the user's email; since generate_otp requires the user email address to generate the otp code.\n\n```python\n# Generates otp code for the user\notp.generate_otp(user_email=user.email) \n```\n\n- Step 4: A base32 secured token and code has been generated, and saved to the secured_otps table. Oh, let's not forget about the scheduler that has been called to remove the user otp and token after the ```SOTP_TIME_EXPIRATION``` has elapsed! 🤝\n\n- Last Step (maybe?): You can call the function anywhere, anytime.\n\nIf you are still finding it difficult to use this package, kindly check the [example app](https://github.com/israelabraham/django-sotp/tree/main/example) I made for reference, or [create an issue](https://github.com/israelabraham/django-sotp/issues) and state the problem you are experiencing!\n\n## Shell Example 🥁\n\nIf you'd like to test out the package on your django shell..\n\n- Step 1: Run the command:\n\n```python\npython manage.py shell\n```\n\n- Step 2: Import the libray directly on the shell:\n\n```python\nfrom sotp.services import GenerateSOTP\n```\n\n- Step 3: Call the generate_otp method, don't forget to add a user email address:\n\n```python\nsecured_otp = otp.generate_otp(user_email=\"test@email.com\") # email should exist :-)\n```\n\n- Step 4: A Token and OTP is generated, and saved to secured_otps database.\n\n```python\n{'totp': '5ZCLA7UQVXFP2B5WL5OZG4QDFDJ4GL65', 'OTP': '957092'}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faybruhm%2Fdjango-sotp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faybruhm%2Fdjango-sotp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faybruhm%2Fdjango-sotp/lists"}