Skip to content

A long-titled repository showing how you could potentially use SvelteKit deployed to Netlify with Google OAuth for authentication.

License

Notifications You must be signed in to change notification settings

duffn/sveltekit-netlify-google-oauth-example

Repository files navigation

sveltekit-netlify-google-oauth-example

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.

Demo

Setup

Local

  • Create OAuth 2.0 credentials for your application.
    • Add an authorized redirect URI entry for http://localhost:3000/auth/callback.
  • 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

Netlify

  • 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 them to your site's build deployment environment variables.
    • Also set NODE_ENV=production and AUTH_REDIRECT=https://my-netlify-app-name.netlify.app/auth/callback.
  • Deploy to Netlify.

Acknowledgements

Thanks to a few different articles and authors for inspiration and help.

License

MIT

About

A long-titled repository showing how you could potentially use SvelteKit deployed to Netlify with Google OAuth for authentication.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published