Git Product home page Git Product logo

duffn / sveltekit-netlify-google-oauth-example Goto Github PK

View Code? Open in Web Editor NEW
7.0 2.0 2.0 348 KB

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

Home Page: https://svelte-google-oauth-example.netlify.app

License: MIT License

JavaScript 17.75% HTML 1.23% Svelte 7.40% CSS 73.63%
svelte sveltekit netlify google-oauth2 google-oauth sveltejs

sveltekit-netlify-google-oauth-example's Introduction

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

sveltekit-netlify-google-oauth-example's People

Contributors

dependabot[bot] avatar duffn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

khadersyed

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.