A Python package for OAuth authentication with various social providers, inspired by Laravel Socialite.
## Installation
```bash
pip install py-socialite
```
## Configuration
Create a configuration file (e.g., config.py) with your OAuth credentials:
```python
# 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'
},
'your_provider_name': {
'client_id': 'your-client-id',
'client_secret': 'your-client-secret',
'redirect_uri': 'your-callback-url'
},
}
```
Set the configuration path in your environment:
```bash
export SOCIALITE_CONFIG_PATH=/path/to/config.py
```
## Usage
```python
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.
```python
try:
user = socialite.provider('google').get_user(code)
except SocialAuthError as e:
print(f"Authentication failed: {str(e)}")
```
## Project Structure
```bash
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
- facebook
- microsoft
## Response sample data
```bash
{
"provider": "google",
"id": "1234567890",
"email": "example@example.com",
"name": "John Doe",
"avatar": "https://example.com/avatar.jpg",
"raw": {
.....
}
}
```
## Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Raw data
{
"_id": null,
"home_page": "https://py-socialite.code4mk.org/",
"name": "py-socialite",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": null,
"keywords": "python, oauth, social-auth, authentication, py-socialite, code4mk",
"author": "Mostafa Kamal",
"author_email": "hiremostafa@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/d8/6e/561a38ad9c855b742ee80a0bbb3af02dc2bca8c6b789b4ff65f8d72fc647/py_socialite-0.0.2.tar.gz",
"platform": null,
"description": "A Python package for OAuth authentication with various social providers, inspired by Laravel Socialite.\n\n## Installation\n\n```bash\npip install py-socialite\n```\n\n## Configuration\n\nCreate a configuration file (e.g., config.py) with your OAuth credentials:\n\n```python\n# config.py\n\nSOCIAL_PROVIDERS = {\n 'google': {\n 'client_id': 'your-client-id',\n 'client_secret': 'your-client-secret',\n 'redirect_uri': 'your-callback-url'\n },\n 'github': {\n 'client_id': 'your-client-id',\n 'client_secret': 'your-client-secret',\n 'redirect_uri': 'your-callback-url'\n },\n 'dropbox': {\n 'client_id': 'your-client-id',\n 'client_secret': 'your-client-secret',\n 'redirect_uri': 'your-callback-url'\n },\n 'x': {\n 'client_id': 'your-client-id',\n 'client_secret': 'your-client-secret',\n 'redirect_uri': 'your-callback-url'\n },\n 'your_provider_name': {\n 'client_id': 'your-client-id',\n 'client_secret': 'your-client-secret',\n 'redirect_uri': 'your-callback-url'\n },\n \n}\n```\nSet the configuration path in your environment:\n\n```bash\nexport SOCIALITE_CONFIG_PATH=/path/to/config.py\n```\n\n## Usage\n\n```python\nfrom py_socialite.socialite import Socialite\n\n# Initialize Socialite\nsocialite = Socialite()\n\n# Get authorization URL\nauth_url = socialite.provider('google').get_auth_url()\n\n# After callback, get user info\nuser = socialite.provider('google').get_user(code)\n```\n\n## Error Handling\n\nThe package raises `SocialAuthError` for any authentication issues.\n\n```python\ntry:\n user = socialite.provider('google').get_user(code)\nexcept SocialAuthError as e:\n print(f\"Authentication failed: {str(e)}\")\n```\n\n## Project Structure\n\n```bash\npy-socialite/\n\u251c\u2500\u2500 py_socialite/\n\u2502 \u251c\u2500\u2500 __init__.py # Version and package info\n\u2502 \u251c\u2500\u2500 exceptions.py # Custom exceptions\n\u2502 \u251c\u2500\u2500 config.py # Provider configurations\n\u2502 \u251c\u2500\u2500 socialite.py # Main service class\n\u2502 \u2514\u2500\u2500 providers/\n\u2502 \u251c\u2500\u2500 base.py # Abstract base provider\n\u2502 \u2514\u2500\u2500 google.py # Google implementation\n\u251c\u2500\u2500 setup.py # Package setup\n\u2514\u2500\u2500 deploy.sh # Deployment script\n```\n\n## Requirements\n\n- python 3.10+\n- requests\n- python-dotenv\n\n## support providers\n\n- google\n- github\n- dropbox\n- x\n- facebook\n- microsoft\n\n## Response sample data\n\n```bash\n{\n \"provider\": \"google\",\n \"id\": \"1234567890\",\n \"email\": \"example@example.com\",\n \"name\": \"John Doe\",\n \"avatar\": \"https://example.com/avatar.jpg\",\n \"raw\": {\n .....\n }\n}\n```\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n",
"bugtrack_url": null,
"license": null,
"summary": "A Python package for OAuth authentication with various social providers.",
"version": "0.0.2",
"project_urls": {
"Changelog": "https://github.com/code4mk/py-socialite/blob/main/CHANGELOG.md",
"Homepage": "https://py-socialite.code4mk.org/",
"Source": "https://github.com/code4mk/py-socialite"
},
"split_keywords": [
"python",
" oauth",
" social-auth",
" authentication",
" py-socialite",
" code4mk"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "5e00e829f2aa6a5bb0d10b6b4f9256ad72e77dbf47a7d945da5ed6871c0582b7",
"md5": "23460ace96c93e0dbb4b3970e27ccf73",
"sha256": "020037c23cc67755340e2bbe97aa50a0e4698e98479494ce9bddcf3050ec881d"
},
"downloads": -1,
"filename": "py_socialite-0.0.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "23460ace96c93e0dbb4b3970e27ccf73",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 3973,
"upload_time": "2025-01-06T21:53:36",
"upload_time_iso_8601": "2025-01-06T21:53:36.524749Z",
"url": "https://files.pythonhosted.org/packages/5e/00/e829f2aa6a5bb0d10b6b4f9256ad72e77dbf47a7d945da5ed6871c0582b7/py_socialite-0.0.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "d86e561a38ad9c855b742ee80a0bbb3af02dc2bca8c6b789b4ff65f8d72fc647",
"md5": "2e857ca0db88c3c59876bfb76547472a",
"sha256": "d0b933e677ca6bf27a8f544524da6ff7da7bac5d61ec1a228b4624b632fbf703"
},
"downloads": -1,
"filename": "py_socialite-0.0.2.tar.gz",
"has_sig": false,
"md5_digest": "2e857ca0db88c3c59876bfb76547472a",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 4106,
"upload_time": "2025-01-06T21:53:39",
"upload_time_iso_8601": "2025-01-06T21:53:39.737218Z",
"url": "https://files.pythonhosted.org/packages/d8/6e/561a38ad9c855b742ee80a0bbb3af02dc2bca8c6b789b4ff65f8d72fc647/py_socialite-0.0.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-01-06 21:53:39",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "code4mk",
"github_project": "py-socialite",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "py-socialite"
}