Skip to main content

discord oauth2

Project description

sanic-discord

example

from sanic import Sanic
from sanic.response import text
from sanic_discord import Client, Config

app = Sanic("app")
client = Client(
    Config(
        secret="secret",
        id="clientid",
        login_url="login url",
        callback_url="https://example.com/callback",
        redirect_url="/me"
    )
)

@app.route("/callback")
async def callback(request):
    return await client.callback(request)
    
@app.route("/me")
@client.oauth2_required()
async def me(request, user):
    return text(user["username"] + "hello")

app.run("0.0.0.0", 8000)

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

sanic-discord-1.0.0a2.tar.gz (7.1 kB view hashes)

Uploaded Source

Built Distribution

sanic_discord-1.0.0a2-py3-none-any.whl (9.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page