Swift OAuth2 Client
Swift OAuth2 Client is a Python SDK that provides a simple and efficient way to interact with OAuth2-protected APIs. It handles token management, API calls, and file downloads with support for asynchronous operations.
Features
- Asynchronous API calls using
httpx - Automatic token management and renewal
- Support for various request body types and response formats
- File download capabilities
- Easy-to-use interface with type hints
- Comprehensive documentation
Installation
pip install swift-oauth2-client
Quick Start
Here's a basic example of how to use the Swift OAuth2 Client:
from oauth2_client import OAuth2Config, new_api_client
config = OAuth2Config(
token_url="https://api.example.com/oauth/token",
client_id="your_client_id",
client_secret="your_client_secret",
scopes=["read", "write"]
)
with new_api_client(config, "https://api.example.com") as client:
response, status, content_type = client.call_api("GET", "/users")
print(f"Status: {status}, Content Type: {content_type}, Response: {response}")
Asynchronous usage:
import asyncio
from oauth2_client import OAuth2Config, new_api_client_async
async def main():
config = OAuth2Config(
token_url="https://api.example.com/oauth/token",
client_id="your_client_id",
client_secret="your_client_secret",
scopes=["read", "write"]
)
async with new_api_client_async(config, "https://api.example.com") as client:
response, status, content_type = await client.call_api("GET", "/users")
print(f"Status: {status}, Content Type: {content_type}, Response: {response}")
asyncio.run(main())
For more comprehensive examples, check out the examples/oauth2_client_example_async.py and examples/oauth2_client_example.pyfiles in the repository.
Documentation
For detailed documentation, including API reference and usage guides, visit our documentation site.
Development
To set up the development environment:
- Ensure you have Poetry installed
- Clone the repository
- Run
poetry installto install dependencies - Run tests with
poetry run pytest
Docs
- Build documentation with
poetry run mkdocs build - Serve the documentation with
poetry run mkdocs serve. - Open a web browser and go to http://127.0.0.1:8000/.
License
This project is licensed under the Apache License, Version 2.0.
Metadata
Release files for swift-oauth2-client 0.6.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| swift_oauth2_client-0.6.0.tar.gz | 10.9 kB | Without provenance | Details for swift_oauth2_client-0.6.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| swift_oauth2_client-0.6.0-py3-none-any.whl | Python 3 | none | any | Details for swift_oauth2_client-0.6.0-py3-none-any.whl |
Total release size: 24.3 kB
Release files / swift_oauth2_client-0.6.0.tar.gz
| Download URL | swift_oauth2_client-0.6.0.tar.gz |
|---|---|
| Size | 10.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1f28092ce804b89ff262b88edaa504d03520d25e4742bc491124d5ca36a26d7b
|
|
BLAKE2b-256 checksum How to use checksums |
0aa8ca9058b4d18ff28cdd38bf75423bef78b38a8288c6d4c22608da90aa5cec
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.12.0 Darwin/23.6.0
|
Release files / swift_oauth2_client-0.6.0-py3-none-any.whl
| Download URL | swift_oauth2_client-0.6.0-py3-none-any.whl |
|---|---|
| Size | 13.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a37b8c37575751fe9ac581bab71ee909e59e1ea46f674e82b62327c9036289b4
|
|
BLAKE2b-256 checksum How to use checksums |
802ffa663fc99517294c40009ac7d6ecb4c90f870067e1372551dd44a7bc022c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.12.0 Darwin/23.6.0
|
Security for swift-oauth2-client 0.6.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.