Skip to content

Auth.js / Next-Auth external API example(s) with a Go backend API server using JWE auth middleware

Notifications You must be signed in to change notification settings

mjyocca/authjs-external-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Authjs External Api

Auth.js social sign in example with an external API backend written in GO. The GO API server uses JWE (Json Web Encryption) A256GCM middleware that aligns with the Auth.js/Next-auth Package when JWT is enabled.

Authjs Providers:

  • Github
  • Google

Frontend (Nextjs)

Setup

Generate secret to use with both frontend and backend used as the NEXTAUTH_SECRET

openssl rand -base64 32

Create env file .env.local

GITHUB_ID=[INFO HERE]
GITHUB_SECRET=[INFO HERE]

GOOGLE_CLIENT_ID=[INFO HERE]
GOOGLE_CLIENT_SECRET=[INFO HERE]

NEXTAUTH_URL=http://localhost:3000
NEXTAUTH_SECRET=[INFO HERE]

EXTERNAL_API_ENDPOINT=http://localhost:8000

Start Frontend Service

Need pnpm installed

pnpm install \
pnpm dev

Backend (Go)

Create env file .env.local

NEXTAUTH_SECRET=[INFO HERE]

Start Backend Service

cd backend \
docker compose up

About

Auth.js / Next-Auth external API example(s) with a Go backend API server using JWE auth middleware

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published