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.2.tar.gz
(10.2 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.2.tar.gz.
File metadata
- Download URL: pycord_quart-0.1.2.tar.gz
- Upload date:
- Size: 10.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2861d8f2767d105194cd0d98054026021ba67367afeb1464c4a0947f460853b7
|
|
| MD5 |
54df6b19c8153e8b78d159734692772c
|
|
| BLAKE2b-256 |
31009bdf50b8888303c4c421a4c0f27a9015cb7a00f35aff4596b84e16af8fed
|
File details
Details for the file pycord_quart-0.1.2-py3-none-any.whl.
File metadata
- Download URL: pycord_quart-0.1.2-py3-none-any.whl
- Upload date:
- Size: 8.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
79135ffcdc5f85759bba31efd9fe5f266d379a00d5d934d462f11306a86da1d6
|
|
| MD5 |
e51338eab35876b867f76eed6be03a9c
|
|
| BLAKE2b-256 |
0dcccc0c9c9e3026edf366c5f3860fcbde4beb8e60792499d95853d9fe977d7c
|