Python SDK for AuthGate — OAuth 2.0 authentication and token management
Project description
AuthGate Python SDK
Python SDK for AuthGate — OAuth 2.0 authentication and token management.
Installation
pip install go-authgate
With framework support:
pip install go-authgate[fastapi]
pip install go-authgate[flask]
pip install go-authgate[django]
Quick Start
from authgate import authenticate
client, token = authenticate(
"https://auth.example.com",
"my-client-id",
scopes=["profile", "email"],
)
print(f"Access token: {token.access_token}")
Async Usage
from authgate import async_authenticate
client, token = await async_authenticate(
"https://auth.example.com",
"my-client-id",
scopes=["profile", "email"],
)
Client Credentials (M2M)
from authgate.oauth import OAuthClient, Endpoints
from authgate.clientcreds import TokenSource, BearerAuth
import httpx
client = OAuthClient("my-service", endpoints, client_secret="secret")
ts = TokenSource(client, scopes=["api"])
# Auto-attaches Bearer token to every request
with httpx.Client(auth=BearerAuth(ts)) as http:
resp = http.get("https://api.example.com/data")
Middleware
FastAPI
from fastapi import FastAPI, Depends
from authgate.middleware.fastapi import BearerAuth
from authgate.middleware.models import TokenInfo
app = FastAPI()
auth = BearerAuth(oauth_client)
@app.get("/protected")
async def protected(info: TokenInfo = Depends(auth)):
return {"user": info.user_id}
Flask
from flask import Flask
from authgate.middleware.flask import bearer_auth, get_token_info
app = Flask(__name__)
@app.route("/protected")
@bearer_auth(oauth_client)
def protected():
info = get_token_info()
return {"user": info.user_id}
Development
make install # uv sync --all-extras
make test
make lint
make typecheck
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file go_authgate-0.1.0.tar.gz.
File metadata
- Download URL: go_authgate-0.1.0.tar.gz
- Upload date:
- Size: 93.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
80069537e40504aac9b353d7f5867c41b170daa6e286d27510c54129e9677a68
|
|
| MD5 |
5c20fa503ff098a9583b70062a20ff20
|
|
| BLAKE2b-256 |
298eaf38d8d546f132d0b19bd181ffb19a8b51898dabe78a65119cde89fc8a02
|
Provenance
The following attestation bundles were made for go_authgate-0.1.0.tar.gz:
Publisher:
release.yml on go-authgate/sdk-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
go_authgate-0.1.0.tar.gz -
Subject digest:
80069537e40504aac9b353d7f5867c41b170daa6e286d27510c54129e9677a68 - Sigstore transparency entry: 1121502178
- Sigstore integration time:
-
Permalink:
go-authgate/sdk-python@146c88d3f32c01a133bc4713b50575329ceb3dd4 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/go-authgate
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@146c88d3f32c01a133bc4713b50575329ceb3dd4 -
Trigger Event:
push
-
Statement type:
File details
Details for the file go_authgate-0.1.0-py3-none-any.whl.
File metadata
- Download URL: go_authgate-0.1.0-py3-none-any.whl
- Upload date:
- Size: 33.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bf0d86b20aeb8d5cb0065e42d21449f2efe7f0f9ee97be546a46fc96ea33b5f0
|
|
| MD5 |
0cb90617424f0d9d005b052a6f28bdfa
|
|
| BLAKE2b-256 |
7a180c938712318a5f88ea77b4174655d455f19b9e026f076bb6aefc708cf7fa
|
Provenance
The following attestation bundles were made for go_authgate-0.1.0-py3-none-any.whl:
Publisher:
release.yml on go-authgate/sdk-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
go_authgate-0.1.0-py3-none-any.whl -
Subject digest:
bf0d86b20aeb8d5cb0065e42d21449f2efe7f0f9ee97be546a46fc96ea33b5f0 - Sigstore transparency entry: 1121502221
- Sigstore integration time:
-
Permalink:
go-authgate/sdk-python@146c88d3f32c01a133bc4713b50575329ceb3dd4 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/go-authgate
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@146c88d3f32c01a133bc4713b50575329ceb3dd4 -
Trigger Event:
push
-
Statement type: