DEV Community

InvalidLenni
InvalidLenni

Posted on

1 1

Quart-Nextcord

Quart-Nextcord - Discord OAuth2 extension for Quart using nextcord.

Quart-Nextcord is an extension for nextcord.

Related links

Example

 from quart import Quart, redirect, url_for 
 from quart_nextcord import DiscordOAuth2Session, requires_authorization, Unauthorized 

 app = Quart(__name__) 

 app.secret_key = b"random bytes representing quart secret key" 

 app.config["DISCORD_CLIENT_ID"] = 490732332240863233  # Discord client ID. 
 app.config["DISCORD_CLIENT_SECRET"] = ""  # Discord client secret. 
 app.config["DISCORD_REDIRECT_URI"] = ""  # URL to your callback endpoint. 
 app.config["DISCORD_BOT_TOKEN"] = ""  # Required to access BOT resources. 

 nextcord = DiscordOAuth2Session(app) 


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


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


 @app.errorhandler(Unauthorized) 
 async def redirect_unauthorized(e): 
     return redirect(url_for("login")) 


 @app.route("/me/") 
 @requires_authorization 
 async def me(): 
     user = await nextcord.fetch_user() 
     return f""" 
     <html> 
         <head> 
             <title>{user.name}</title> 
         </head> 
         <body> 
             <img src='{user.avatar_url}' /> 
         </body> 
     </html>""" 


 if __name__ == "__main__": 
     app.run() 
Enter fullscreen mode Exit fullscreen mode

Ideas?

Go to https://github.com/InvalidLenni/Quart-Nextcord/discussions

You found issues?

Go to https://github.com/InvalidLenni/Quart-Nextcord/issues/new

Contribution

You can make contributions too for helping us! 😃

Sentry blog image

How to reduce TTFB

In the past few years in the web dev world, we’ve seen a significant push towards rendering our websites on the server. Doing so is better for SEO and performs better on low-powered devices, but one thing we had to sacrifice is TTFB.

In this article, we’ll see how we can identify what makes our TTFB high so we can fix it.

Read more

Top comments (0)

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay