FeaturesGoogle Oauth

ShipFast uses NextAuth to authenticate users. You can configure it in the /pages/api/auth/[...nextauth].js file.

Setup

  • If you haven't done it yet, add this to your .env.local:

    .env.local

    1NEXTAUTH_URL=http://localhost:3000
    2NEXTAUTH_SECRET=4348yhu34h3ui4ofjndfsdfeirh4b637u5sfd3
    NEXTAUTH_SECRET is a random chain of characters for JWT encryption. Put anything in there with a least 10 characters.
  • Create a new project on Google Cloud
  • Go to APIs & Services then Credentials
  • Click [Configure Consent Screen]
  • Fill info. Use the ChatGPT prompts in pages /tos & /privacy-policy to generate yours automatically.
    Add userinfo.email & userinfo.profile to scope.
    Add yourself as a test user.
    Submit.
  • Go to Credentials and click [+ Create Credentials] then [Oauth Client ID]
  • Choose [Web Application].
    Add http://localhost:3000 and https://your-site.com to Authorized JavaScript origins.
    Add http://localhost:3000/api/auth/callback/google andhttps://your-site.com/api/auth/callback/google to Authorized redirect URIs.
    Click [Create]
  • Copy paste the Client ID in GOOGLE_ID and Client Secret in GOOGLE_SECRET to .env.local.
  • Go to [Oauth Consent Screen] and click [Publish App] then submit for verification
    Google will email you and you will have to reply to start the process. You'll need to have your domain verified with Google Search Console. You can go ahead and do that now.
    You can already login with Google on localhost. On production, it will work too but show a warning until you're verified (takes a few days).
The mongoDB adapter saves new users in the database when they successfully log in with Google. You have to configure the database first.