Open
Conversation
|
@clxrityy is attempting to deploy a commit to the Jeff's projects Team on Vercel. A member of the Team first needs to authorize it. |
Untitled-developerYT
approved these changes
Aug 28, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
nextjs-discord-bot (with oauth2)
Overview
Accessing the designated root url (
/) will require authentication with Discord. Upon authorizing, the user will beredirected back to the root url (with additional user details displayed)
Replication
OAuth2 URLs
Generate your own OAuth2 redirect URI with every additional scope needed
(
discord.com/applications/CLIENT_ID/oauth2)/api/auth/discord/redirectAdd these urls (development and production) to
config.ts:Discord endpoints
POSTrequest to Discord's oauth token endpoint(
discord.com/api/v10/oauth2/token)access_tokenfrom the data given is used to receive the Discord user's details by making aGETrequest tothe
discord.com/api/v10users/@meendpoint:Vercel Postgres / Prisma
I've implemented a prisma table which will store the encrypted access & refresh token from the user data. This can be used later, but for now has minimal impact on the application.
Prisma is used to store the
Usermodel:Quickstart
Create a postgres database on your vercel dashboard
Retreive the environment variables locally:
Generate the prisma client:
Create the table(s) in your database based on your prisma schema:
buildscript withinpackage.jsonhas been altered to support the prisma database in production:Encryption
crypto-js is used to encrypt the
access_token&refresh_tokenbefore storing into theUsermodel.ENCRYPTION_KEYenvironment variable (make sure to also add this to your vercel project environment variables)Cookies & JWT
jsonwebtoken & cookie are used for signing & serializing the cookie for the user session.
JWT_SECRETenvironment variable (make sure to also add this to your vercel project environment variables)Updates
.env.local.examplehas been updated to include:config.tshas been made to include necesssary authentication URLs