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 for the application to implement osm authentication login to their project with oauth2.0

Auth can be initialized with your credentials like this :

from osm_login_python.core import Auth
osm_auth=Auth(osm_url=settings.OSM_URL, client_id=settings.OSM_CLIENT_ID,client_secret=settings.OSM_CLIENT_SECRET, secret_key=settings.OSM_SECRET_KEY, login_redirect_uri=settings.OSM_LOGIN_REDIRECT_URI, scope=settings.OSM_SCOPE)

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=settings.OSM_URL, client_id=settings.OSM_CLIENT_ID,client_secret=settings.OSM_CLIENT_SECRET, secret_key=settings.OSM_SECRET_KEY, login_redirect_uri=settings.OSM_LOGIN_REDIRECT_URI, scope=settings.OSM_SCOPE)

def login(request):
    login_url=osm_auth.login()
    return JsonResponse(json.loads(login_url))

def callback(request):
    # Generating token through osm_auth library method
    token=osm_auth.callback(request.build_absolute_uri())
    return JsonResponse(json.loads(token))

def get_my_data(request,access_token: str):
    user_data=osm_auth.deserialize_access_token(access_token)
    return JsonResponse(user_data)

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-0.0.2.tar.gz (3.2 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: osm-login-python-0.0.2.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.10

File hashes

Hashes for osm-login-python-0.0.2.tar.gz
Algorithm Hash digest
SHA256 93c06a9c7e0a05b2691f2c42ad3eec037bca593bcacbfbe20e66bc76fbe498f6
MD5 378ee534c1481fc108e0a86722ef881f
BLAKE2b-256 f7d432dd91d8cc8a7df3bdc281f694b6b7a9d23872f8f6daaa7bdb17a566d982

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