Skip to main content

A Python package for OAuth authentication with various social providers.

Project description

A Python package for OAuth authentication with various social providers, inspired by Laravel Socialite.

Installation

pip install py-socialite

Configuration

Create a configuration file (e.g., config.py) with your OAuth credentials:

# config.py

SOCIAL_PROVIDERS = {
    'google': {
        'client_id': 'your-client-id',
        'client_secret': 'your-client-secret',
        'redirect_uri': 'your-callback-url'
    },
    'github': {
        'client_id': 'your-client-id',
        'client_secret': 'your-client-secret',
        'redirect_uri': 'your-callback-url'
    },
    'dropbox': {
        'client_id': 'your-client-id',
        'client_secret': 'your-client-secret',
        'redirect_uri': 'your-callback-url'
    },
    'x': {
        'client_id': 'your-client-id',
        'client_secret': 'your-client-secret',
        'redirect_uri': 'your-callback-url'
    }
}

Set the configuration path in your environment:

export SOCIALITE_CONFIG_PATH=/path/to/config.py

Usage

from py_socialite.socialite import Socialite

# Initialize Socialite
socialite = Socialite()

# Get authorization URL
auth_url = socialite.provider('google').get_auth_url()

# After callback, get user info
user = socialite.provider('google').get_user(code)

Error Handling

The package raises SocialAuthError for any authentication issues.

try:
    user = socialite.provider('google').get_user(code)
except SocialAuthError as e:
    print(f"Authentication failed: {str(e)}")

Project Structure

py-socialite/
├── py_socialite/
│   ├── __init__.py         # Version and package info   ├── exceptions.py       # Custom exceptions   ├── config.py           # Provider configurations   ├── socialite.py        # Main service class   └── providers/
│       ├── base.py         # Abstract base provider       └── google.py       # Google implementation
├── setup.py                # Package setup
└── deploy.sh              # Deployment script

Requirements

  • python 3.10+
  • requests
  • python-dotenv

support providers

  • google
  • github
  • dropbox
  • x

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

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

py_socialite-0.0.1.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

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

py_socialite-0.0.1-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file py_socialite-0.0.1.tar.gz.

File metadata

  • Download URL: py_socialite-0.0.1.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.3

File hashes

Hashes for py_socialite-0.0.1.tar.gz
Algorithm Hash digest
SHA256 786ee20c656e80b8a112f3c92e36c87f8ef3e39124fb6c62e94876d57a25af81
MD5 b2daafc16d98a520dc313496579eb0b4
BLAKE2b-256 586f27082deb14c30dc7ab062bd42c876c3bf14c58a229ad2cc9346115c6d261

See more details on using hashes here.

File details

Details for the file py_socialite-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: py_socialite-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 3.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.3

File hashes

Hashes for py_socialite-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0cd2385098a52e9559ab1c1bda4bc14a98e1eb61d74d9b7aa9ced2f41d4f2a8a
MD5 725672728bf19f5d3c98c9a4bf93c417
BLAKE2b-256 529dbecb89ce363aeff233a3ad1b838065826f0b8da9116a5510cd38125db7a0

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