Skip to main content

Official Python SDK for TSP Scale OAuth Login

Project description

tspscale-login

Official Python SDK for TSP Scale Authentication.

🚀 Quick Start (Zero-Config)

Easily integrate TSP Scale OAuth 2.0 into your Python backends (Django, Flask, FastAPI). This package acts as a full Confidential Client, capable of handling authorization URLs, secure token exchanges, and token verification.

Installation

pip install tspscale-login

🛠️ Usage

1. Generating the Authorization URL

Redirect your users to this URL so they can log in via TSP Scale.

from tspscale_login import TSPClient

client = TSPClient(
    client_id='YOUR_CLIENT_ID',
    client_secret='YOUR_CLIENT_SECRET',
    redirect_uri='http://localhost:8000/callback'
)

auth_url = client.get_authorization_url()
# Redirect your user to `auth_url`

2. Exchanging the Code for a Token

When the user returns to your redirect_uri, they will have a code in the URL parameters.

# Assuming you extracted the `code` from the URL query string
token_data = client.exchange_token(code)

if 'error' in token_data:
    print("Failed to login:", token_data['error'])
else:
    access_token = token_data['access_token']
    print("Successfully retrieved access token!", access_token)

3. Verifying a Token / Getting the User Profile

Once you have an access token (or if you are just verifying a token sent by a React frontend), use verify_token.

from tspscale_login import TSPAuthException

try:
    data = client.verify_token(access_token)
    user_profile = data['user']
    print(f"Logged in as: {user_profile['email']}")
except TSPAuthException as error:
    print(f"Authentication failed: {str(error)}")

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

tspscale_login-1.1.0.tar.gz (3.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tspscale_login-1.1.0-py3-none-any.whl (3.3 kB view details)

Uploaded Python 3

File details

Details for the file tspscale_login-1.1.0.tar.gz.

File metadata

  • Download URL: tspscale_login-1.1.0.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for tspscale_login-1.1.0.tar.gz
Algorithm Hash digest
SHA256 340fa854fd7b1b35fb569f982de8d005199c4a49d9762b09d098eac67fe49939
MD5 293247011c90a2a4fad2292fd5170ca3
BLAKE2b-256 5ef001fa2bba6371ddc46920484a2dc6278cca93ce45291ba28792b732506359

See more details on using hashes here.

File details

Details for the file tspscale_login-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: tspscale_login-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for tspscale_login-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 524ef583981b73fd77d6628af7927501fd172aeb3236525fe4ef7f8d4d875be0
MD5 6c6680fb8540d92c2f719c9b27fc6944
BLAKE2b-256 71bf11511503112e00e33ace0eb77d2673dab44f6fdbe378b52ab508d456e26f

See more details on using hashes here.

Supported by

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