A Next.js application that allows users to generate Google Forms programmatically using OAuth 2.0 authentication.
Before you begin, you need to:
- Have a Google Account
- Set up a Google Cloud Project
- Have an OpenAI API key
- Go to Google Cloud Console
- Create a new project or select an existing one
- Enable the Google Forms API:
- Go to "APIs & Services" > "Library"
- Search for "Google Forms API"
- Click "Enable"
-
In Google Cloud Console:
- Go to "APIs & Services" > "Credentials"
- Click "Create Credentials" > "OAuth client ID"
- Select "Web application"
-
Configure OAuth consent screen:
- Go to "OAuth consent screen"
- Choose "External" user type
- Fill in required app information
- Add scopes:
https://www.googleapis.com/auth/forms.body
https://www.googleapis.com/auth/forms.responses.readonly
-
Configure authorized redirect URIs:
- Add:
http://localhost:3000/auth/callback
(for development) - Add your production URL if deploying
- Add:
-
After creating, you'll receive:
- Client ID
- Client Secret
- Clone the repository:
git clone https://github.com/yourusername/google-form-generator.git
cd google-form-generator
- Install dependencies:
npm install
# or
yarn install
- Create a
.env.local
file in the root directory:
GOOGLE_CLIENT_ID=your_client_id_here
GOOGLE_CLIENT_SECRET=your_client_secret_here
GOOGLE_REDIRECT_URI=http://localhost:3000/auth/callback
NEXT_PUBLIC_API_URL=http://localhost:3000/api
OPENAI_API_KEY=your_openai_api_key_here
- Start the development server:
npm run dev
# or
yarn dev
- Visit
http://localhost:3000
- Click "Sign in with Google"
- Authorize the application
- Enter your form details:
- Title
- Description/Questions (one per line)
- The AI will automatically detect question types:
- Multiple choice questions with options will be RADIO type
- Rating questions will be SCALE type (1-5)
- Questions asking for explanations will be PARAGRAPH type
- Questions with multiple possible answers will be CHECKBOX type
- Simple short answers will be TEXT type
- Click "Generate Form"
- Use the generated form URL to access your new Google Form
- OAuth 2.0 authentication with Google
- Automatic form generation
- AI-powered question type detection using OpenAI
- Support for multiple question types (text, paragraph, radio, checkbox, scale)
- Direct integration with user's Google account
- Forms appear in user's Google Drive
- The application uses the Google Forms API v1
- Forms are created under the authenticated user's account
- Questions are intelligently parsed using OpenAI's GPT model
- Supports various question types based on context and phrasing
-
If authentication fails:
- The application will automatically attempt to refresh expired tokens
- If token refresh fails, you will be redirected to login again
- Verify your OAuth credentials and consent screen configuration
- Check that redirect URIs are correctly configured
- Ensure all required scopes are added to the consent screen
-
If form creation fails:
- Verify the Google Forms API is enabled
- Check the user has granted necessary permissions
- Review API quotas in Google Cloud Console
-
If AI parsing fails:
- Verify your OpenAI API key is correct
- Check the API key has sufficient credits
- Ensure the API key has the necessary permissions
- OAuth tokens are stored in localStorage (consider more secure alternatives for production)
- Always use HTTPS in production
- Keep your Google Cloud credentials secure
- Protect your OpenAI API key and never expose it client-side