Name | osm-login-python JSON |
Version |
1.0.2
JSON |
| download |
home_page | |
Summary | Use OSM Token exchange with OAuth2.0 for python projects. |
upload_time | 2023-12-06 04:00:41 |
maintainer | |
docs_url | None |
author | |
requires_python | >=3.9 |
license | GPL-3.0-only |
keywords |
osm
openstreetmap
oauth2
login
hot
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# osm-login-python
Library to provide osm login oauth2.0 exchange to python projects
Makes it very easier to implement osm authentication login to
their project with oauth2.0
📖 [Documentation](https://hotosm.github.io/osm-login-python/)
## Install with [pip](https://pypi.org/project/osm-login-python/)
```bash
pip install osm-login-python
```
## Import Auth and initialize class with your credentials
```python
from osm_login_python.core import Auth
```
```python
osm_auth=Auth(
osm_url=YOUR_OSM_URL,
client_id=YOUR_OSM_CLIENT_ID,
client_secret=YOUR_OSM_CLIENT_SECRET,
secret_key=YOUR_OSM_SECRET_KEY,
login_redirect_uri=YOUR_OSM_LOGIN_REDIRECT_URI,
scope=YOUR_OSM_SCOPE,
)
```
## Usage
Provides 3 Functions inside Auth class :
1. login() -- Returns the login url for osm
2. callback() -- Returns the access token for the user
3. deserialize_access_token() -- returns the user data
## Example
On django :
```python
from django.conf import settings
from osm_login_python.core import Auth
from django.http import JsonResponse
import json
# initialize osm_auth with our credentials
osm_auth=Auth(
osm_url=YOUR_OSM_URL,
client_id=YOUR_OSM_CLIENT_ID,
client_secret=YOUR_OSM_CLIENT_SECRET,
secret_key=YOUR_OSM_SECRET_KEY,
login_redirect_uri=YOUR_OSM_LOGIN_REDIRECT_URI,
scope=YOUR_OSM_SCOPE,
)
def login(request):
login_url=osm_auth.login()
return JsonResponse(login_url)
def callback(request):
# Generating token through osm_auth library method
token=osm_auth.callback(request.build_absolute_uri())
return JsonResponse(token)
def get_my_data(request,access_token: str):
user_data=osm_auth.deserialize_access_token(access_token)
return JsonResponse(user_data)
```
- Check Django integration example here
<https://github.com/hotosm/fAIr/tree/master/backend/login>
- Check FastAPI integration example here
<https://github.com/hotosm/export-tool-api/tree/develop/API/auth>
### Version Control
Use [commitizen](https://pypi.org/project/commitizen/) for version control
### Contirbute
Contributions are welcome !
Raw data
{
"_id": null,
"home_page": "",
"name": "osm-login-python",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": "",
"keywords": "osm,openstreetmap,oauth2,login,hot",
"author": "",
"author_email": "Kshitij Raj Sharma <skshitizraj@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/46/b4/d49da63d95ffa821fa74a5ebf2545245ffcd253b721c9fd89ef7370f129b/osm-login-python-1.0.2.tar.gz",
"platform": null,
"description": "# osm-login-python\n\nLibrary to provide osm login oauth2.0 exchange to python projects\n\nMakes it very easier to implement osm authentication login to\ntheir project with oauth2.0\n\n\ud83d\udcd6 [Documentation](https://hotosm.github.io/osm-login-python/)\n\n## Install with [pip](https://pypi.org/project/osm-login-python/)\n\n```bash\npip install osm-login-python\n```\n\n## Import Auth and initialize class with your credentials\n\n```python\nfrom osm_login_python.core import Auth\n```\n\n```python\nosm_auth=Auth(\n osm_url=YOUR_OSM_URL,\n client_id=YOUR_OSM_CLIENT_ID,\n client_secret=YOUR_OSM_CLIENT_SECRET,\n secret_key=YOUR_OSM_SECRET_KEY,\n login_redirect_uri=YOUR_OSM_LOGIN_REDIRECT_URI,\n scope=YOUR_OSM_SCOPE,\n)\n```\n\n## Usage\n\nProvides 3 Functions inside Auth class :\n\n1. login() -- Returns the login url for osm\n2. callback() -- Returns the access token for the user\n3. deserialize_access_token() -- returns the user data\n\n## Example\n\nOn django :\n\n```python\nfrom django.conf import settings\nfrom osm_login_python.core import Auth\nfrom django.http import JsonResponse\nimport json\n\n# initialize osm_auth with our credentials\nosm_auth=Auth(\n osm_url=YOUR_OSM_URL,\n client_id=YOUR_OSM_CLIENT_ID,\n client_secret=YOUR_OSM_CLIENT_SECRET,\n secret_key=YOUR_OSM_SECRET_KEY,\n login_redirect_uri=YOUR_OSM_LOGIN_REDIRECT_URI,\n scope=YOUR_OSM_SCOPE,\n)\n\ndef login(request):\n login_url=osm_auth.login()\n return JsonResponse(login_url)\n\ndef callback(request):\n # Generating token through osm_auth library method\n token=osm_auth.callback(request.build_absolute_uri())\n return JsonResponse(token)\n\ndef get_my_data(request,access_token: str):\n user_data=osm_auth.deserialize_access_token(access_token)\n return JsonResponse(user_data)\n```\n\n- Check Django integration example here\n <https://github.com/hotosm/fAIr/tree/master/backend/login>\n\n- Check FastAPI integration example here\n <https://github.com/hotosm/export-tool-api/tree/develop/API/auth>\n\n### Version Control\n\nUse [commitizen](https://pypi.org/project/commitizen/) for version control\n\n### Contirbute\n\nContributions are welcome !\n\n",
"bugtrack_url": null,
"license": "GPL-3.0-only",
"summary": "Use OSM Token exchange with OAuth2.0 for python projects.",
"version": "1.0.2",
"project_urls": {
"documentation": "https://hotosm.github.io/osm-login-python",
"homepage": "https://hotosm.github.io/osm-login-python",
"repository": "https://github.com/hotosm/osm-login-python"
},
"split_keywords": [
"osm",
"openstreetmap",
"oauth2",
"login",
"hot"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "7ba64e37b653c450b75c1b4f3f52b58bc0b4d8d65765510311248e390c6630d6",
"md5": "08efae5aaa5e14daa5cc2da6fe472852",
"sha256": "49c02b84630496a07801f0e1a658e332817ac3d27cf0607b3c43bd5718ed19cf"
},
"downloads": -1,
"filename": "osm_login_python-1.0.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "08efae5aaa5e14daa5cc2da6fe472852",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 15896,
"upload_time": "2023-12-06T04:00:39",
"upload_time_iso_8601": "2023-12-06T04:00:39.783464Z",
"url": "https://files.pythonhosted.org/packages/7b/a6/4e37b653c450b75c1b4f3f52b58bc0b4d8d65765510311248e390c6630d6/osm_login_python-1.0.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "46b4d49da63d95ffa821fa74a5ebf2545245ffcd253b721c9fd89ef7370f129b",
"md5": "778df82a7cd695380e8baa0b5d0964da",
"sha256": "3876ae64e74d6e1452f20dbcdde8fca4f3604d5d9d046a8982dfb1db10520c77"
},
"downloads": -1,
"filename": "osm-login-python-1.0.2.tar.gz",
"has_sig": false,
"md5_digest": "778df82a7cd695380e8baa0b5d0964da",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 15473,
"upload_time": "2023-12-06T04:00:41",
"upload_time_iso_8601": "2023-12-06T04:00:41.691471Z",
"url": "https://files.pythonhosted.org/packages/46/b4/d49da63d95ffa821fa74a5ebf2545245ffcd253b721c9fd89ef7370f129b/osm-login-python-1.0.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-12-06 04:00:41",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "hotosm",
"github_project": "osm-login-python",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "osm-login-python"
}