Skip to main content
After completing the OAuth setup for each provider, OAuth Init offers multiple options for saving your credentials. Choose the format that best fits your project structure and workflow.

Available Save Options

OAuth Init supports four different save formats:
Save credentials to a .env file in your project root.File: .env
GOOGLE_CLIENT_ID=your-client-id.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=your-client-secret
When to use:
  • Standard Node.js projects
  • Projects using dotenv package
  • When you want a single environment file
Behavior:
  • If .env exists, OAuth Init will prompt to append credentials
  • If .env doesn’t exist, it will be created
  • Credentials are appended with a newline separator

Credential Format

Regardless of the save option, credentials follow a consistent naming pattern:
{PROVIDER}_CLIENT_ID=<value>
{PROVIDER}_CLIENT_SECRET=<value>
Where {PROVIDER} is the uppercase provider name:
  • Google: GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET
  • GitHub: GITHUB_CLIENT_ID, GITHUB_CLIENT_SECRET
  • Discord: DISCORD_CLIENT_ID, DISCORD_CLIENT_SECRET

Appending to Existing Files

When saving to .env or .env.local, OAuth Init checks if the file already exists:
.env already exists. Append credentials? (Y/n)
If you choose to append:
  • New credentials are added with a newline separator
  • Existing content is preserved
  • No duplicate checking is performed
If you decline:
  • Credentials are not saved
  • You’ll see: “Credentials not saved.”

Multiple Providers

When setting up multiple OAuth providers, you can choose different save options for each: Example workflow:
# Google setup
Credentials saved to .env

# GitHub setup
Credentials saved to .env

# Discord setup
Discord credentials printed to console
All providers can append to the same .env or .env.local file:
GOOGLE_CLIENT_ID=google-client-id
GOOGLE_CLIENT_SECRET=google-secret
GITHUB_CLIENT_ID=github-client-id
GITHUB_CLIENT_SECRET=github-secret
DISCORD_CLIENT_ID=discord-client-id
DISCORD_CLIENT_SECRET=discord-secret

Security Best Practices

Always add credential files to .gitignore to prevent accidentally committing secrets to version control.
Recommended .gitignore entries:
.env
.env.local
*-credentials.json
Additional recommendations:
  • Use .env.local for local development in Next.js projects
  • Use environment variable management systems in production
  • Rotate credentials if they’re accidentally exposed
  • Never commit .env files with real credentials

Choosing the Right Option

ScenarioRecommended Option
Next.js local development.env.local
Standard Node.js project.env
Custom config systemJSON
CI/CD pipelinePrint to console
Docker/KubernetesPrint to console
Cloud platform deploymentPrint to console
Multiple environments.env.local for local, print for others

Build docs developers (and LLMs) love