A pycord extension for Discord OAuth2 authentication in Quart applications.
Project description
pycord-quart
A pycord extension for Discord OAuth2 authentication in Quart applications.
Installation
Python >= 3.10.x is required.
# Windows
pip install --upgrade pycord-quart
# Linux
pip3 install --upgrade pycord-quart
Examples
from quart import Quart, request, session, redirect, url_for, jsonify
from pycord.ipc import Client
from pycord.quart import DiscordAuth, require_auth, get_current_user
app = Quart(__name__)
ipc_client = Client(secret_key=<"your IPCSecret">, host=<"your IPC Server IP">, port=<"your IPC Server Port">)
app.config["SECRET_KEY"] = <"your SecretKey">
discord_auth = DiscordAuth(
client_id=<"your DiscordClientID">,
client_secret=<"your DiscordClientSecret">,
redirect_uri=<"your DiscordRedirectURI">,
scopes=['identify', 'email', 'guilds'],
)
@app.route("/api/auth/login", methods=["GET"])
async def api_login():
response = await discord_auth.login_handler()
return jsonify(response.to_json), response.code
@app.route("/api/auth/callback", methods=["GET"])
async def api_callback():
response = await discord_auth.callback_handler()
return jsonify(response.to_json), response.code
@app.route("/api/auth/logout", methods=["POST"])
async def api_logout():
response = await discord_auth.logout_handler()
return jsonify(response.to_json), response.code
if __name__ == "__main__":
app.run(host="0.0.0.0", port=8080, debug=True)
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
pycord_quart-0.1.1.tar.gz
(10.3 kB
view details)
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 pycord_quart-0.1.1.tar.gz.
File metadata
- Download URL: pycord_quart-0.1.1.tar.gz
- Upload date:
- Size: 10.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7f75ea7e150d345cc4c2653f48e52d5c953ac4a350d56b1557c830ba6a72ddea
|
|
| MD5 |
b3483639c28e5779cfacae05c4262797
|
|
| BLAKE2b-256 |
372692b0488243437778cdc965d7a222f4c76b9a836b8029d71560aab5805ef4
|
File details
Details for the file pycord_quart-0.1.1-py3-none-any.whl.
File metadata
- Download URL: pycord_quart-0.1.1-py3-none-any.whl
- Upload date:
- Size: 8.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8d5b7e4ee6b187c9b1d94e88dcc98978930da2946e4a294a2c0614cda374030c
|
|
| MD5 |
ffe4aef028d11ab000bd5389d7180ed9
|
|
| BLAKE2b-256 |
4b29a95a826c8dbf2d3ea9869da39ff516067d5795dea7e4da65a380c43b5dcc
|