A long-titled repository showing how you could potentially use SvelteKit deployed to Netlify with Google OAuth for authentication. Not the only way or perhaps even the best way, but a way.
- Create OAuth 2.0 credentials for your application.
- Add an authorized redirect URI entry for
http://localhost:3000/auth/callback
.
- Add an authorized redirect URI entry for
- Copy
.env.sample
to.env
- Generate secrets for JWT and cookie signing.
node -p "require('crypto').randomBytes(64).toString('hex');"
- Optionally set
AUTHORIZED_DOMAIN
to restrict authentication to only this domain. - The other values can remain the same for local development.
- Install dependencies and run.
npm install
npm run dev
- Generate new OAuth 2.0 credentials and secrets for Netlify.
- Add a new authorized redirect URI entry for
https://my-netlify-app-name.netlify.app/auth/callback
.
- Add a new authorized redirect URI entry for
- Add them to your site's build deployment environment variables.
- Also set
NODE_ENV=production
andAUTH_REDIRECT=https://my-netlify-app-name.netlify.app/auth/callback
.
- Also set
- Deploy to Netlify.
Thanks to a few different articles and authors for inspiration and help.