cyrux

Guides

Google Authentication

Cyrux uses better auth for authentication, check it's docs for more information.

Setup

  1. 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.

  1. Create a new project in Google Cloud Console and select it.
  2. Go to APIs & Services then Credentials
  3. Click [Oauth Consent Screen] and then get started
  4. Fill your project info in this form and create project
  • Audience : External

Google Oauth Page

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

  2. Fill the following info OAuth Client Form and click create.

FieldValue
Application typeWeb Application
Name[Dosen't matter add anything]
Authorized JavaScript originshttp://localhost:3000 & https://[yourdomain]
Authorized redirect URIshttp://localhost:3000/api/auth/callback/google & https://[yourdomain]/api/auth/callback/google
  1. 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]
  1. All done, you can now login using your google account.

Go to http://localhost:3000/sign-in and click on login with google button

On this page