{"id":18790905,"url":"https://github.com/ahmetkotan/tokenauth","last_synced_at":"2025-04-13T14:20:25.030Z","repository":{"id":57476113,"uuid":"167800253","full_name":"ahmetkotan/tokenauth","owner":"ahmetkotan","description":"Django Simple Token Authentication with Expiration Time and Prefix","archived":false,"fork":false,"pushed_at":"2019-01-28T06:50:35.000Z","size":7,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-27T05:22:28.387Z","etag":null,"topics":["django","expire","refresh","rest","token"],"latest_commit_sha":null,"homepage":null,"language":"Python","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/ahmetkotan.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-01-27T11:17:17.000Z","updated_at":"2022-07-18T20:20:56.000Z","dependencies_parsed_at":"2022-09-07T17:13:11.543Z","dependency_job_id":null,"html_url":"https://github.com/ahmetkotan/tokenauth","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahmetkotan%2Ftokenauth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahmetkotan%2Ftokenauth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahmetkotan%2Ftokenauth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahmetkotan%2Ftokenauth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ahmetkotan","download_url":"https://codeload.github.com/ahmetkotan/tokenauth/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248725064,"owners_count":21151619,"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":["django","expire","refresh","rest","token"],"created_at":"2024-11-07T21:14:01.007Z","updated_at":"2025-04-13T14:20:25.009Z","avatar_url":"https://github.com/ahmetkotan.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"=====================================================================\n Tokenauth\n=====================================================================\nTokenauth developed for django rest token authentication. It enables you to define expiration time and token prefix. Tokens generate with random data and it use SHA-256 algorithm.\n\nInstallation\n============\non Pypi\n::\n  pip install tokenauth\non Github\n::\n  git clone git@github.com:ahmetkotan/tokenauth.git\n  cd tokenauth\n  python setup.py install\n\nSettings\n============\nAdded to `INSTALLED_APPS`.\n::\n\n  INSTALLED_APPS = [\n      ...\n      'tokenauth',\n      ...\n  ]\n\nAdded to `urls.py`.\n::\n  urlpatterns = [\n      ...\n      url(r'^\u003cyour-login-url\u003e/', include('tokenauth.urls')),\n      ...\n]\n\nDefinition in `settings.py`\n::\n  TOKEN_EXPIRATION_TIME = 60 * 60 * 24 * 3 # Default 3 days\n  TOKEN_PREFIX = \"Bearer\"\n  TOKEN_REFRESH = True\n\nUsage\n=====\nDefinition in `settings.py`\n::\n  # Rest Framework\n  REST_FRAMEWORK = {\n      ...\n      'DEFAULT_AUTHENTICATION_CLASSES': (\n          'tokenauth.auth.TokenAuthentication',\n      ),\n      ...\n  }\n\nOr in `views.py`\n::\n  from tokenauth.auth import TokenAuthentication\n  class SimpleView(ModelViewset):\n      authentication_classes = (TokenAuthentication, )\n\n\nCreated token and login:\n::\n  curl -X POST -H \"Content-Type: application/json\" -d '{\"username\": \"\u003cusername\u003e\", \"password\":\"\u003cpassword\u003e\"}' \u003cyour-django-url\u003e/\u003cyour-login-url\u003e/tokens/\n\nRefresh token:\n::\n  curl -X PUT -H \"Content-Type: application/json\" -d '{\"key\": \"\u003cyour-valid-token\u003e\"}' \u003cyour-django-url\u003e/\u003cyour-login-url\u003e/tokens/\n\nDeleted token and logout:\n::\n  curl -X DELETE -H \"Content-Type: application/json\" -H \"Authorization: \u003cyour-token\u003e\" \u003cyour-django-url\u003e/\u003cyour-login-url\u003e/tokens/\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fahmetkotan%2Ftokenauth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fahmetkotan%2Ftokenauth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fahmetkotan%2Ftokenauth/lists"}