google auth
I created an app using mage, and didn't include google authentication. I would now like to add that functionality. What is the simplest way to add that functionality?
main.wasp file. This will enable Google Authentication with default settings. Here's how to do it:main.wasp file:.env.server file at the root of your project:main.wasp file:wasp db migrate-dev and wasp start should give you a working app with Google Authentication. source (https://wasp-lang.dev/docs/auth/social-auth/google#conclusion)wasp start command.wasp start, the client will go for port 3001, causing the server to fail because its port is taken. source (πquestionsFrontend React Template integration into OpenSaas template).env.server file. source (https://wasp-lang.dev/docs/auth/social-auth/google#4-adding-environment-variables).js for JavaScript or .ts for TypeScript).GOOGLE_CLIENT_ID=your-google-client-id
GOOGLE_CLIENT_SECRET=your-google-client-secret google: {}auth.methodsapp.auth.userEntitySocialButtonSocialButtonSocialButtonGoogle.jsx<http://localhost:3001/auth/google/callbackGOOGLE_CLIENT_IDGOOGLE_CLIENT_SECRETsrc/auth/userSignupFieldsuserSignupFieldsuserSignupFieldsuserSignupFieldsuserSignupFieldsuserSignupFieldsuserSignupFieldsuserSignupFieldssrc/auth/google.tsgoogle.tssrc/auth/...app myApp {
wasp: {
version: "^0.13.0"
},
title: "My App",
auth: {
userEntity: User,
methods: {
google: {}
},
onAuthFailedRedirectTo: "/login"
},
} entity User {=psl
id Int @id @default(autoincrement())
// ...
psl=} route LoginRoute { path: "/login", to: LoginPage }
page LoginPage {
component: import { Login } from "@src/pages/auth.jsx"
} import { userSignupFields } from '../../../../../../../src/auth/userSignupFields'import { defineUserSignupFields } from 'wasp/server/auth'
export const userSignupFields = defineUserSignupFields({
address: async (data) => {
const address = data.address
if (typeof address !== 'string') {
throw new Error('Address is required')
}
if (address.length < 5) {
throw new Error('Address must be at least 5 characters long')
}
return address
},
})