#I'm having trouble getting Google

1 messages · Page 1 of 1 (latest)

bronze linden
#

in order to get it to work with my users document schema, I had to add this to my providers

  GoogleProvider({
    clientId: process.env.GOOGLE_CLIENT_ID,
    clientSecret: process.env.GOOGLE_CLIENT_SECRET,
    scope: 'openid profile email',
    profile: (profile) => {
      const { id, sub, name, email, picture } = profile
      const now = new Date()

      return {
        id: sub, name, email, picture, username: email,
        emailVerified: now, tosAgreedAt: now, privacyAgreedAt: now, marketingAgreedAt: now,
        referralDiscount: 20, referralCommission: 10,
      }
    }
  })
#

here is what my callbacks look like

  callbacks: {
    async signIn({ user, account, profile }) {
      return true
    },

    async session({ session, token }) {
      console.dir({ session, token })
      const user = await getUserFromDb(session.user.email);

      if (user) {
        session.user.id = token.sub
      }

      console.dir({ session: { user, session } })
      return Promise.resolve({
        ...session,
        user,
      })
    },

    async jwt({ token, user }) {
      console.dir({ token, user })

      return token
    }
  },
  session: {
    strategy: "jwt", // Store sessions in the database and store a sessionToken in the cookie for lookups
  },