Skip to main content

Use OSM Token exchange with OAuth2.0 for python projects.

Project description

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

Install with pip

pip install osm-login-python

Import Auth and initialize class with your credentials

from osm_login_python.core import Auth
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 :

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)

Version Control

Use commitizen for version control

Contirbute

Contributions are welcome !

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

osm-login-python-1.0.3.tar.gz (15.5 kB view details)

Uploaded Source

Built Distribution

osm_login_python-1.0.3-py3-none-any.whl (15.9 kB view details)

Uploaded Python 3

File details

Details for the file osm-login-python-1.0.3.tar.gz.

File metadata

  • Download URL: osm-login-python-1.0.3.tar.gz
  • Upload date:
  • Size: 15.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.9.3 CPython/3.10.12

File hashes

Hashes for osm-login-python-1.0.3.tar.gz
Algorithm Hash digest
SHA256 b9737e74b2daf63b3e5e06032013ea3fd0f9bedf618e3581db84bdc2b791b865
MD5 8780826aab35459e426e0d2163897582
BLAKE2b-256 ee8c681dfaaa74d7c3a30db8f2b7e741083daae5c1cba68be7d5aeb1d4f4880b

See more details on using hashes here.

File details

Details for the file osm_login_python-1.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for osm_login_python-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 64c37a7d1c7cac211551a589a6f8ffafc641b29e27d608c94e52ab6cb531f937
MD5 f0f14f86f7677b4e9489508de1b0db21
BLAKE2b-256 353f6fdafe9a2aef3b0127641b0b830188e3c2daf86bfec7680f1843f76ed570

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page