Guides
Google Authentication
Cyrux uses better auth for authentication, check it's docs for more information.
Setup
- If you still haven't, run the following commands to add env variables to your convex dashboard.
npx convex env set SITE_URL http://localhost:3000
npx convex env set BETTER_AUTH_SECRET=$(openssl rand -base64 32)Set your site url to https://[yourdomain] in production.
- Create a new project in Google Cloud Console and select it.
- Go to APIs & Services then Credentials
- Click [Oauth Consent Screen] and then get started
- Fill your project info in this form and create project
- Audience : External

-
Now you'll end up on this page, click on [Create OAuth client] and it will open a form.

-
Fill the following info OAuth Client Form and click create.
| Field | Value |
|---|---|
| Application type | Web Application |
| Name | [Dosen't matter add anything] |
| Authorized JavaScript origins | http://localhost:3000 & https://[yourdomain] |
| Authorized redirect URIs | http://localhost:3000/api/auth/callback/google & https://[yourdomain]/api/auth/callback/google |
- Copy your client id and client secret and run the following commands in your terminal to add env variables to your convex dev deployment.
npx convex env set GOOGLE_CLIENT_ID [your client id]
npx convex env set GOOGLE_CLIENT_SECRET [your client secret]- All done, you can now login using your google account.
Go to http://localhost:3000/sign-in and click on login with google button