Skip to content

Add support for base64 encoded credentials#7

Open
sam-at-luther wants to merge 1 commit intomainfrom
feature/add-base64-credentials-support
Open

Add support for base64 encoded credentials#7
sam-at-luther wants to merge 1 commit intomainfrom
feature/add-base64-credentials-support

Conversation

@sam-at-luther
Copy link
Member

Summary

This PR adds support for base64 encoded credentials passed as environment variables, enabling better containerized deployments without file system dependencies.

Changes

Added Environment Variables

  • ****: Base64 encoded OAuth client credentials (gcp-oauth.keys.json)
  • ****: Base64 encoded user OAuth tokens (.gdrive-server-credentials.json)

Implementation

  • Added decodeBase64Json() helper function to decode and parse base64 JSON strings
  • Updated loadCredentialsAndRunServer() to check for base64 env vars before falling back to file paths
  • Maintains full backwards compatibility with existing file-based approach

Documentation

  • Added comprehensive section in README about base64 credential usage
  • Included examples for generating base64 encoded credentials
  • Documented environment variable priority order

Benefits

  1. Better containerized deployments: No file system dependencies
  2. Simplified secrets management: Credentials can be injected as env vars from secret stores
  3. Consistent with Google Sheets connector: Aligns with the base64 pattern used in mcp-server-google-sheets
  4. Backwards compatible: Existing deployments continue to work without changes

Testing

✅ Build successful
✅ TypeScript compilation passed
✅ Backwards compatible with existing file-based credentials

Environment Variable Priority

OAuth Client Credentials:

  1. (base64 encoded)
  2. (file path)
  3. Default: credentials/gcp-oauth.keys.json

User Credentials:

  1. (base64 encoded)
  2. (file path)
  3. Default: credentials/.gdrive-server-credentials.json

Example Usage

# Generate base64 encoded credentials
base64 < credentials/gcp-oauth.keys.json | tr -d '\n'
base64 < credentials/.gdrive-server-credentials.json | tr -d '\n'

# Use in environment
export OAUTH_CREDENTIALS_JSON_B64="ewogICJpbnN0YWxsZWQi..."
export GDRIVE_CREDENTIALS_JSON_B64="ewogICJhY2Nlc3NfdG9rZW4i..."
node dist/index.js

Related

- Added OAUTH_CREDENTIALS_JSON_B64 environment variable for OAuth client credentials
- Added GDRIVE_CREDENTIALS_JSON_B64 environment variable for user OAuth tokens
- Both variables allow credentials to be provided as base64 encoded JSON strings
- Falls back to file paths if base64 env vars not provided
- Updated README with documentation and examples for base64 credentials
- Maintains full backwards compatibility with existing file-based approach

This change enables better containerized deployments by avoiding file system dependencies
and simplifies credential management in Docker/Kubernetes environments.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant