Quart-Authorization-Discord 1.0.3

Last updated:

0 purchases

Quart-Authorization-Discord 1.0.3 Image
Quart-Authorization-Discord 1.0.3 Images
Add to Cart

Description:

QuartAuthorizationDiscord 1.0.3

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.

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.