Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/duffn/sveltekit-netlify-google-oauth-example
A long-titled repository showing how you could potentially use SvelteKit deployed to Netlify with Google OAuth for authentication.
https://github.com/duffn/sveltekit-netlify-google-oauth-example
google-oauth google-oauth2 netlify svelte sveltejs sveltekit
Last synced: 25 days ago
JSON representation
A long-titled repository showing how you could potentially use SvelteKit deployed to Netlify with Google OAuth for authentication.
- Host: GitHub
- URL: https://github.com/duffn/sveltekit-netlify-google-oauth-example
- Owner: duffn
- License: mit
- Created: 2021-10-24T01:24:29.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-01-05T07:28:11.000Z (almost 2 years ago)
- Last Synced: 2024-05-01T14:29:59.595Z (6 months ago)
- Topics: google-oauth, google-oauth2, netlify, svelte, sveltejs, sveltekit
- Language: CSS
- Homepage: https://svelte-google-oauth-example.netlify.app
- Size: 340 KB
- Stars: 7
- Watchers: 2
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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](https://svelte-google-oauth-example.netlify.app)
## Setup
### Local
- Create [OAuth 2.0 credentials](https://support.google.com/cloud/answer/6158849?hl=en) 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
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](https://docs.netlify.com/configure-builds/environment-variables/).
- Also set `NODE_ENV=production` and `AUTH_REDIRECT=https://my-netlify-app-name.netlify.app/auth/callback`.
- [Deploy to Netlify](https://docs.netlify.com/site-deploys/create-deploys/).## Acknowledgements
Thanks to a few different articles and authors for inspiration and help.
- [Sveltekit Authentication](https://blog.hyper.io/sveltekit-authentication/)
- [Serverless OAuth with Multiple Providers](https://ryanbethel.org/serverless-o-auth-with-multiple-providers)
- [Creative Tim Tailwind Starter](https://www.creative-tim.com/learning-lab/tailwind-starter-kit/presentation)## License
[MIT](https://opensource.org/licenses/MIT)