Skip to main content

Quart Discord Authorization Library

Project description

Quart-Authorization

A Library For Quart Discord Authorization

Note: This Fixed Version Of This Package

Whats Changed In This Package?

  • Some Errors Fixed Like Unclosed Clients
  • logout() Function Errors Fixed
  • Added .is_logged() Function

Usage

from Quart_Authorization_Discord import DiscordOauth2Client
from Quart import Quart, redirect, url_for, render_template_string

app = Quart(__name__)
app.secret_key = b"random bytes representing quart secret key"
app.config['DISCORD_CLIENT_ID'] = "Client ID here"
app.config['DISCORD_CLIENT_SECRET'] = 'CLIENT_SECRET_HERE'
app.config['SCOPES'] = ['identify', 'guilds']
app.config['DISCORD_REDIRECT_URI'] = 'http://127.0.0.1:5000/callback'
app.config['DISCORD_BOT_TOKEN'] = "Token"

client = DiscordOauth2Client(app)

@app.route("/")
async def index():
    if client.is_logged():
        return "You Are Already Logged In, Go To This Page: /me"
    else:
        return "You Are Not Logged In, Go To Authorization: /login"

@app.route("/login")
async def login():
    return await client.create_session()

@app.route("/logout")
async def logout():
    await client.logout()
    return redirect(url_for("index"))

@app.route("/callback")
async def callback():
    await client.callback()
    return redirect(url_for("index"))

@app.route("/me")
@client.is_logged_in # Checks If User Logged In, Raises 401
async def me():
    user = await client.fetch_user()
    return await render_template_string("""<html><head></head>
<body><p>You Are Succesfully Logged In As {{user.name}}</p>
</html>    
""",user=user)

@app.errorhandler(401)
async def handle_unathorized(e):
    return redirect(url_for("login"))

if __name__ == "__main__":
    app.run()

This Package Still On Development.

Bugs And Errors Can Be Found While Using. Please Contact Me If You Found Any Of These.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

Quart_Authorization_Discord-1.0.3-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file Quart_Authorization_Discord-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: Quart_Authorization_Discord-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 8.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.6

File hashes

Hashes for Quart_Authorization_Discord-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 a0453652cb4d535fd12f78b5282af1805f0cd5e6ed2d873f25dcb8d9955579bc
MD5 345328b6813eb4a70ced867bc95d4f7a
BLAKE2b-256 45fe433e16e6114d0b87008fe6b97bb61ccb6ccf8556a0593b850d23ac641bce

See more details on using hashes here.

Supported by

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