Name | shopify-multipass-auth JSON |
Version |
0.1.1
JSON |
| download |
home_page | https://github.com/autonomous-tech/shopify-multipass-auth |
Summary | A Python library for generating Shopify multipass tokens for customer authentication |
upload_time | 2025-08-10 05:27:23 |
maintainer | None |
docs_url | None |
author | Usama Mashood |
requires_python | >=3.7 |
license | MIT License
Copyright (c) 2025 Your Name
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
|
keywords |
shopify
multipass
authentication
ecommerce
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Shopify Multipass
[](https://badge.fury.io/py/shopify-multipass)
[](https://pypi.org/project/shopify-multipass/)
[](https://opensource.org/licenses/MIT)
A Python library for generating Shopify multipass tokens for customer authentication.
## Overview
This library provides a simple interface to generate Shopify multipass tokens, which allow you to authenticate customers on your Shopify store without requiring them to enter their credentials. Multipass is particularly useful for integrating external systems with Shopify stores while providing a seamless user experience.
## Features
- ๐ Generate multipass tokens for customer authentication
- ๐ Create complete login URLs with embedded tokens
- โ
Validate email formats and Shopify domains
- ๐ก๏ธ Support for both `.myshopify.com` domains and custom domains
- ๐ Comprehensive error handling with descriptive messages
- ๐ Type hints for better IDE support
- ๐งช Extensive test coverage
## Installation
Install from PyPI:
```bash
pip install shopify-multipass
```
Or install from source:
```bash
git clone https://github.com/yourusername/shopify-multipass.git
cd shopify-multipass
pip install -e .
```
### Requirements
- Python 3.7+
- pycryptodome>=3.20.0
## Quick Start
```python
from shopify_multipass import MultiPass
# Initialize with your Shopify multipass secret
multipass = MultiPass("your_multipass_secret_here")
# Generate a complete login URL (most common use case)
result = multipass.generate_login_url(
email="customer@example.com",
domain="your-shop.myshopify.com",
return_to="https://your-shop.myshopify.com/pages/welcome"
)
if result["error"] == 0:
print(f"Login URL: {result['redirect']}")
else:
print(f"Error: {result['message']}")
```
## API Reference
### MultiPass Class
#### `__init__(secret: str)`
Initialize the multipass service with your Shopify multipass secret.
**Parameters:**
- `secret` (str): Your Shopify multipass secret key
**Raises:**
- `ValueError`: If secret is empty or None
#### `get_token_only(email: str, return_to: str) -> dict`
Generate only a multipass token for the given email and return URL.
**Parameters:**
- `email` (str): Customer email address
- `return_to` (str): URL to redirect to after authentication
**Returns:**
- `dict`: Response with error code and token or error message
```python
# Success
{"error": 0, "token": "generated_token_here"}
# Error
{"error": 1, "message": "Error description"}
```
#### `get_login_url_with_token(token: str, domain: str) -> dict`
Generate a login URL using an existing token and domain.
**Parameters:**
- `token` (str): Previously generated multipass token
- `domain` (str): Shopify domain for multipass authentication
**Returns:**
- `dict`: Response with error code and redirect URL or error message
```python
# Success
{"error": 0, "redirect": "https://domain.com/account/login/multipass/token"}
# Error
{"error": 1, "message": "Error description"}
```
#### `generate_login_url(email: str, domain: str, return_to: str) -> dict`
Generate a complete multipass login URL for a customer.
**Parameters:**
- `email` (str): Customer email address
- `domain` (str): Shopify domain for multipass authentication
- `return_to` (str): URL to redirect to after authentication
**Returns:**
- `dict`: Response with error code and redirect URL or error message
## Usage Examples
### Basic Token Generation
```python
from shopify_multipass import MultiPass
multipass = MultiPass("your_secret_key")
# Generate just a token
token_result = multipass.get_token_only(
email="customer@example.com",
return_to="https://shop.com/welcome"
)
if token_result["error"] == 0:
token = token_result["token"]
print(f"Generated token: {token}")
```
### Generate Login URL from Existing Token
```python
# Use a previously generated token
url_result = multipass.get_login_url_with_token(
token="previously_generated_token",
domain="your-shop.myshopify.com"
)
if url_result["error"] == 0:
print(f"Login URL: {url_result['redirect']}")
```
### Complete Workflow
```python
from shopify_multipass import MultiPass
def authenticate_customer(email, shop_domain, welcome_page):
multipass = MultiPass("your_multipass_secret")
result = multipass.generate_login_url(
email=email,
domain=shop_domain,
return_to=welcome_page
)
if result["error"] == 0:
# Redirect customer to this URL
return result["redirect"]
else:
# Handle error
raise Exception(f"Authentication failed: {result['message']}")
# Usage
login_url = authenticate_customer(
email="customer@example.com",
shop_domain="mystore.myshopify.com",
welcome_page="https://mystore.myshopify.com/pages/dashboard"
)
```
## Error Handling
All methods return a dictionary with an `error` field:
- `error: 0` - Success
- `error: 1` - Error occurred, check `message` field for details
Common error scenarios:
- Invalid or missing email address
- Invalid domain format
- Missing required parameters
- Encryption/signing errors
```python
result = multipass.generate_login_url(email, domain, return_to)
if result["error"] == 1:
print(f"Error occurred: {result['message']}")
# Handle error appropriately
else:
# Use result["redirect"] or result["token"]
pass
```
## Domain Validation
The library validates Shopify domains and supports:
- Standard Shopify domains: `shop-name.myshopify.com`
- Custom domains: `shop.example.com`
- URLs with or without protocol (automatically adds `https://`)
## Security Notes
1. **Keep your multipass secret secure** - Never expose it in client-side code
2. **Use HTTPS** - Always use secure connections for multipass URLs
3. **Validate return URLs** - Ensure return_to URLs are trusted domains
4. **Token expiration** - Multipass tokens have a limited lifetime (configurable in Shopify)
## Testing
Run the test suite:
```bash
python -m unittest tests/test_multipass.py -v
```
The test suite includes:
- Token generation and validation
- URL creation and formatting
- Email and domain validation
- Error handling scenarios
- Cryptographic operations
## Development
### Project Structure
```
shopify_multipass/
โโโ __init__.py # Package initialization
โโโ multipass.py # Main MultiPass class
โโโ __pycache__/
tests/
โโโ __init__.py
โโโ test_multipass.py # Comprehensive test suite
requirements.txt # Dependencies
```
## Contributing
We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
### Development Setup
1. Clone the repository:
```bash
git clone https://github.com/yourusername/shopify-multipass.git
cd shopify-multipass
```
2. Create a virtual environment:
```bash
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
```
3. Install development dependencies:
```bash
pip install -e .
pip install -r requirements.txt
```
4. Run tests:
```bash
python -m unittest tests/test_multipass.py -v
```
### Building for PyPI
1. Install build tools:
```bash
pip install build twine
```
2. Build the package:
```bash
python -m build
```
3. Upload to PyPI:
```bash
python -m twine upload dist/*
```
## Changelog
See [CHANGELOG.md](CHANGELOG.md) for a detailed history of changes.
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## Shopify Multipass Setup
To use this library, you need to:
1. **Enable multipass in your Shopify admin:**
- Go to Settings > Checkout
- Scroll down to "Customer accounts"
- Enable "Multipass"
- Copy your multipass secret
2. **Configure your application:**
```python
from shopify_multipass import MultiPass
# Use your actual multipass secret from Shopify
multipass = MultiPass("your_actual_multipass_secret_from_shopify")
```
3. **Set up your authentication flow:**
```python
# In your application
def shopify_login(request):
email = request.user.email
shop_domain = "your-shop.myshopify.com"
return_url = "https://your-shop.myshopify.com/pages/welcome"
result = multipass.generate_login_url(email, shop_domain, return_url)
if result["error"] == 0:
return redirect(result["redirect"])
else:
return JsonResponse({"error": result["message"]})
```
For more information about Shopify multipass, visit the [Shopify documentation](https://shopify.dev/docs/api/multipass).
## Support
- ๐ [Documentation](https://github.com/yourusername/shopify-multipass#readme)
- ๐ [Bug Reports](https://github.com/yourusername/shopify-multipass/issues)
- ๐ฌ [Discussions](https://github.com/yourusername/shopify-multipass/discussions)
- ๐ง [Email Support](mailto:your.email@example.com)
Raw data
{
"_id": null,
"home_page": "https://github.com/autonomous-tech/shopify-multipass-auth",
"name": "shopify-multipass-auth",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": "Usama Mashood <usama@autonomoustech.ca>",
"keywords": "shopify, multipass, authentication, ecommerce",
"author": "Usama Mashood",
"author_email": "Usama Mashood <usama@autonomoustech.ca>",
"download_url": "https://files.pythonhosted.org/packages/04/22/8d57a11978c3b568949bc5f1d5ae2df06375d73f1b6ad7e5c08101ee8302/shopify_multipass_auth-0.1.1.tar.gz",
"platform": null,
"description": "# Shopify Multipass\n\n[](https://badge.fury.io/py/shopify-multipass)\n[](https://pypi.org/project/shopify-multipass/)\n[](https://opensource.org/licenses/MIT)\n\nA Python library for generating Shopify multipass tokens for customer authentication.\n\n## Overview\n\nThis library provides a simple interface to generate Shopify multipass tokens, which allow you to authenticate customers on your Shopify store without requiring them to enter their credentials. Multipass is particularly useful for integrating external systems with Shopify stores while providing a seamless user experience.\n\n## Features\n\n- \ud83d\udd10 Generate multipass tokens for customer authentication\n- \ud83d\udd17 Create complete login URLs with embedded tokens\n- \u2705 Validate email formats and Shopify domains\n- \ud83d\udee1\ufe0f Support for both `.myshopify.com` domains and custom domains\n- \ud83d\udcdd Comprehensive error handling with descriptive messages\n- \ud83d\udd0d Type hints for better IDE support\n- \ud83e\uddea Extensive test coverage\n\n## Installation\n\nInstall from PyPI:\n\n```bash\npip install shopify-multipass\n```\n\nOr install from source:\n\n```bash\ngit clone https://github.com/yourusername/shopify-multipass.git\ncd shopify-multipass\npip install -e .\n```\n\n### Requirements\n\n- Python 3.7+\n- pycryptodome>=3.20.0\n\n## Quick Start\n\n```python\nfrom shopify_multipass import MultiPass\n\n# Initialize with your Shopify multipass secret\nmultipass = MultiPass(\"your_multipass_secret_here\")\n\n# Generate a complete login URL (most common use case)\nresult = multipass.generate_login_url(\n email=\"customer@example.com\",\n domain=\"your-shop.myshopify.com\",\n return_to=\"https://your-shop.myshopify.com/pages/welcome\"\n)\n\nif result[\"error\"] == 0:\n print(f\"Login URL: {result['redirect']}\")\nelse:\n print(f\"Error: {result['message']}\")\n```\n\n## API Reference\n\n### MultiPass Class\n\n#### `__init__(secret: str)`\n\nInitialize the multipass service with your Shopify multipass secret.\n\n**Parameters:**\n- `secret` (str): Your Shopify multipass secret key\n\n**Raises:**\n- `ValueError`: If secret is empty or None\n\n#### `get_token_only(email: str, return_to: str) -> dict`\n\nGenerate only a multipass token for the given email and return URL.\n\n**Parameters:**\n- `email` (str): Customer email address\n- `return_to` (str): URL to redirect to after authentication\n\n**Returns:**\n- `dict`: Response with error code and token or error message\n ```python\n # Success\n {\"error\": 0, \"token\": \"generated_token_here\"}\n \n # Error\n {\"error\": 1, \"message\": \"Error description\"}\n ```\n\n#### `get_login_url_with_token(token: str, domain: str) -> dict`\n\nGenerate a login URL using an existing token and domain.\n\n**Parameters:**\n- `token` (str): Previously generated multipass token\n- `domain` (str): Shopify domain for multipass authentication\n\n**Returns:**\n- `dict`: Response with error code and redirect URL or error message\n ```python\n # Success\n {\"error\": 0, \"redirect\": \"https://domain.com/account/login/multipass/token\"}\n \n # Error\n {\"error\": 1, \"message\": \"Error description\"}\n ```\n\n#### `generate_login_url(email: str, domain: str, return_to: str) -> dict`\n\nGenerate a complete multipass login URL for a customer.\n\n**Parameters:**\n- `email` (str): Customer email address\n- `domain` (str): Shopify domain for multipass authentication\n- `return_to` (str): URL to redirect to after authentication\n\n**Returns:**\n- `dict`: Response with error code and redirect URL or error message\n\n## Usage Examples\n\n### Basic Token Generation\n\n```python\nfrom shopify_multipass import MultiPass\n\nmultipass = MultiPass(\"your_secret_key\")\n\n# Generate just a token\ntoken_result = multipass.get_token_only(\n email=\"customer@example.com\",\n return_to=\"https://shop.com/welcome\"\n)\n\nif token_result[\"error\"] == 0:\n token = token_result[\"token\"]\n print(f\"Generated token: {token}\")\n```\n\n### Generate Login URL from Existing Token\n\n```python\n# Use a previously generated token\nurl_result = multipass.get_login_url_with_token(\n token=\"previously_generated_token\",\n domain=\"your-shop.myshopify.com\"\n)\n\nif url_result[\"error\"] == 0:\n print(f\"Login URL: {url_result['redirect']}\")\n```\n\n### Complete Workflow\n\n```python\nfrom shopify_multipass import MultiPass\n\ndef authenticate_customer(email, shop_domain, welcome_page):\n multipass = MultiPass(\"your_multipass_secret\")\n \n result = multipass.generate_login_url(\n email=email,\n domain=shop_domain,\n return_to=welcome_page\n )\n \n if result[\"error\"] == 0:\n # Redirect customer to this URL\n return result[\"redirect\"]\n else:\n # Handle error\n raise Exception(f\"Authentication failed: {result['message']}\")\n\n# Usage\nlogin_url = authenticate_customer(\n email=\"customer@example.com\",\n shop_domain=\"mystore.myshopify.com\",\n welcome_page=\"https://mystore.myshopify.com/pages/dashboard\"\n)\n```\n\n## Error Handling\n\nAll methods return a dictionary with an `error` field:\n- `error: 0` - Success\n- `error: 1` - Error occurred, check `message` field for details\n\nCommon error scenarios:\n- Invalid or missing email address\n- Invalid domain format\n- Missing required parameters\n- Encryption/signing errors\n\n```python\nresult = multipass.generate_login_url(email, domain, return_to)\n\nif result[\"error\"] == 1:\n print(f\"Error occurred: {result['message']}\")\n # Handle error appropriately\nelse:\n # Use result[\"redirect\"] or result[\"token\"]\n pass\n```\n\n## Domain Validation\n\nThe library validates Shopify domains and supports:\n- Standard Shopify domains: `shop-name.myshopify.com`\n- Custom domains: `shop.example.com`\n- URLs with or without protocol (automatically adds `https://`)\n\n## Security Notes\n\n1. **Keep your multipass secret secure** - Never expose it in client-side code\n2. **Use HTTPS** - Always use secure connections for multipass URLs\n3. **Validate return URLs** - Ensure return_to URLs are trusted domains\n4. **Token expiration** - Multipass tokens have a limited lifetime (configurable in Shopify)\n\n## Testing\n\nRun the test suite:\n\n```bash\npython -m unittest tests/test_multipass.py -v\n```\n\nThe test suite includes:\n- Token generation and validation\n- URL creation and formatting\n- Email and domain validation\n- Error handling scenarios\n- Cryptographic operations\n\n## Development\n\n### Project Structure\n\n```\nshopify_multipass/\n\u251c\u2500\u2500 __init__.py # Package initialization\n\u251c\u2500\u2500 multipass.py # Main MultiPass class\n\u2514\u2500\u2500 __pycache__/\n\ntests/\n\u251c\u2500\u2500 __init__.py\n\u2514\u2500\u2500 test_multipass.py # Comprehensive test suite\n\nrequirements.txt # Dependencies\n```\n\n## Contributing\n\nWe welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.\n\n### Development Setup\n\n1. Clone the repository:\n ```bash\n git clone https://github.com/yourusername/shopify-multipass.git\n cd shopify-multipass\n ```\n\n2. Create a virtual environment:\n ```bash\n python -m venv venv\n source venv/bin/activate # On Windows: venv\\Scripts\\activate\n ```\n\n3. Install development dependencies:\n ```bash\n pip install -e .\n pip install -r requirements.txt\n ```\n\n4. Run tests:\n ```bash\n python -m unittest tests/test_multipass.py -v\n ```\n\n### Building for PyPI\n\n1. Install build tools:\n ```bash\n pip install build twine\n ```\n\n2. Build the package:\n ```bash\n python -m build\n ```\n\n3. Upload to PyPI:\n ```bash\n python -m twine upload dist/*\n ```\n\n## Changelog\n\nSee [CHANGELOG.md](CHANGELOG.md) for a detailed history of changes.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## Shopify Multipass Setup\n\nTo use this library, you need to:\n\n1. **Enable multipass in your Shopify admin:**\n - Go to Settings > Checkout\n - Scroll down to \"Customer accounts\"\n - Enable \"Multipass\"\n - Copy your multipass secret\n\n2. **Configure your application:**\n ```python\n from shopify_multipass import MultiPass\n \n # Use your actual multipass secret from Shopify\n multipass = MultiPass(\"your_actual_multipass_secret_from_shopify\")\n ```\n\n3. **Set up your authentication flow:**\n ```python\n # In your application\n def shopify_login(request):\n email = request.user.email\n shop_domain = \"your-shop.myshopify.com\"\n return_url = \"https://your-shop.myshopify.com/pages/welcome\"\n \n result = multipass.generate_login_url(email, shop_domain, return_url)\n \n if result[\"error\"] == 0:\n return redirect(result[\"redirect\"])\n else:\n return JsonResponse({\"error\": result[\"message\"]})\n ```\n\nFor more information about Shopify multipass, visit the [Shopify documentation](https://shopify.dev/docs/api/multipass).\n\n## Support\n\n- \ud83d\udcd6 [Documentation](https://github.com/yourusername/shopify-multipass#readme)\n- \ud83d\udc1b [Bug Reports](https://github.com/yourusername/shopify-multipass/issues)\n- \ud83d\udcac [Discussions](https://github.com/yourusername/shopify-multipass/discussions)\n- \ud83d\udce7 [Email Support](mailto:your.email@example.com)\n",
"bugtrack_url": null,
"license": "MIT License\n \n Copyright (c) 2025 Your Name\n \n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n \n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n \n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n ",
"summary": "A Python library for generating Shopify multipass tokens for customer authentication",
"version": "0.1.1",
"project_urls": {
"Bug Tracker": "https://github.com/autonomous-tech/shopify-multipass-auth/issues",
"Documentation": "https://github.com/autonomous-tech/shopify-multipass-auth#readme",
"Homepage": "https://github.com/autonomous-tech/shopify-multipass-auth",
"Repository": "https://github.com/autonomous-tech/shopify-multipass-auth"
},
"split_keywords": [
"shopify",
" multipass",
" authentication",
" ecommerce"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "0f1ca81b15741b4bd18a80f7de04561e34462a33b1033777e52e9230b2daff46",
"md5": "641bd846960004e3cd31f3235caa674f",
"sha256": "f561f627563fb0c8ac7814fb280c69a4dce20f71506c6f9bf6848cbd73fd8abe"
},
"downloads": -1,
"filename": "shopify_multipass_auth-0.1.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "641bd846960004e3cd31f3235caa674f",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 9519,
"upload_time": "2025-08-10T05:27:22",
"upload_time_iso_8601": "2025-08-10T05:27:22.281289Z",
"url": "https://files.pythonhosted.org/packages/0f/1c/a81b15741b4bd18a80f7de04561e34462a33b1033777e52e9230b2daff46/shopify_multipass_auth-0.1.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "04228d57a11978c3b568949bc5f1d5ae2df06375d73f1b6ad7e5c08101ee8302",
"md5": "dd09060bad1a987588ff1daa1dc55bcd",
"sha256": "dfbc0667881aca64f027f60605c42ca91de3945d78f45ba34df3f932b2e74447"
},
"downloads": -1,
"filename": "shopify_multipass_auth-0.1.1.tar.gz",
"has_sig": false,
"md5_digest": "dd09060bad1a987588ff1daa1dc55bcd",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 20186,
"upload_time": "2025-08-10T05:27:23",
"upload_time_iso_8601": "2025-08-10T05:27:23.393384Z",
"url": "https://files.pythonhosted.org/packages/04/22/8d57a11978c3b568949bc5f1d5ae2df06375d73f1b6ad7e5c08101ee8302/shopify_multipass_auth-0.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-10 05:27:23",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "autonomous-tech",
"github_project": "shopify-multipass-auth",
"github_not_found": true,
"lcname": "shopify-multipass-auth"
}