{ "info": { "author": "Zorig", "author_email": "zorig.ganbold@gmail.com", "bugtrack_url": null, "classifiers": [ "Environment :: Web Environment", "Framework :: Django", "Framework :: Django :: 2.0", "Framework :: Django :: 2.1", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Topic :: Internet :: WWW/HTTP", "Topic :: Internet :: WWW/HTTP :: Dynamic Content" ], "description": "Django rest Bearer Auth\n---\n\nMust have installed `rest_framework`, then install `bearer-auth` via pip and add it to `settings.py`\n\n```python\npip install django-rest-auth-bearer\n```\n\n```python\nINSTALLED_APPS: [\n ...,\n 'rest_framework',\n 'bearer_auth',\n]\n```\n\nAdd custom authentication to `BearerTokenAuth`\n\n```python\n 'DEFAULT_AUTHENTICATION_CLASSES': (\n 'rest_framework.authentication.SessionAuthentication',\n 'bearer_auth.authentication.BearerTokenAuth',\n ),\n```\n\nAdd `TOKEN_EXPIRES_IN` timespan to `settings.py`\n\n```python\nTOKEN_EXPIRES_IN = 2 #2hours\n```\n\nCustomize `urls.py`\n\n```python\nfrom bearer_auth.views import ObtainToken\n\n...\npath('auth/token', ObtainToken.as_view()),\n```\n\nFrom frontend side, send request as following for acquire token\n\n```json\n\"username\": \"username\",\n\"password\": \"password123\",\n\"grant_type\": \"password\" //must be password\n```\nAs for response:\n```json\n{\n \"token_type\":\"Bearer\",\n \"access_token\":\"c2fbea30732f113bbf879e51b2e49544d2de2d10\"\n \"refresh_token\":\"8ab39baa8f29041a891767a9323500073c9ee8e89e944af759\",\n \"expires_in\":1\n}\n```\n\nMoreover to refresh current token, send `refresh_token` value with grant_type `refresh_token` to same endpoint\n\n```json\n{\n \"refresh_token\":\"8ab39baa8f29041a891767a9323500073c9ee8e89e944af759\",\n \"grant_type\": \"refresh_token\"\n}\n```\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/zorig/django-rest-auth-bearer", "keywords": "", "license": "MIT License", "maintainer": "", "maintainer_email": "", "name": "django-rest-auth-bearer", "package_url": "https://pypi.org/project/django-rest-auth-bearer/", "platform": "", "project_url": "https://pypi.org/project/django-rest-auth-bearer/", "project_urls": { "Homepage": "https://github.com/zorig/django-rest-auth-bearer" }, "release_url": "https://pypi.org/project/django-rest-auth-bearer/0.1.1/", "requires_dist": null, "requires_python": "", "summary": "Bearer auth for DRF.", "version": "0.1.1" }, "last_serial": 4392969, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "fdd970ada1aae6f8115b93dc7a846e45", "sha256": "0e64705b6896b7f94688ac555f98d89929292e3f0e9e0df63547820d1c62ce2d" }, "downloads": -1, "filename": "django-rest-auth-bearer-0.1.tar.gz", "has_sig": false, "md5_digest": "fdd970ada1aae6f8115b93dc7a846e45", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4906, "upload_time": "2018-10-19T05:37:14", "url": "https://files.pythonhosted.org/packages/57/6b/f9ced4154d9c661c938ffbb76dd73d0ef25b2f48173e522cbdb48b5d1383/django-rest-auth-bearer-0.1.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "1b3271835a2be881b17b1c4bd842c689", "sha256": "998c8421491d2a333e42948dd8a17bc10494dd713b2a5cb5dbddda2ea435a484" }, "downloads": -1, "filename": "django-rest-auth-bearer-0.1.1.tar.gz", "has_sig": false, "md5_digest": "1b3271835a2be881b17b1c4bd842c689", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4908, "upload_time": "2018-10-19T06:00:00", "url": "https://files.pythonhosted.org/packages/95/cc/02351dd3254e610d183b7fc2779f32c4bbfcdf1b2abe369f6801b176181f/django-rest-auth-bearer-0.1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "1b3271835a2be881b17b1c4bd842c689", "sha256": "998c8421491d2a333e42948dd8a17bc10494dd713b2a5cb5dbddda2ea435a484" }, "downloads": -1, "filename": "django-rest-auth-bearer-0.1.1.tar.gz", "has_sig": false, "md5_digest": "1b3271835a2be881b17b1c4bd842c689", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4908, "upload_time": "2018-10-19T06:00:00", "url": "https://files.pythonhosted.org/packages/95/cc/02351dd3254e610d183b7fc2779f32c4bbfcdf1b2abe369f6801b176181f/django-rest-auth-bearer-0.1.1.tar.gz" } ] }