Skip to content

fix: generate Google Drive connection code for embedded environments#9884

Merged
Light2Dark merged 1 commit into
mainfrom
sham/gdrive-local-webserver-flow
Jun 15, 2026
Merged

fix: generate Google Drive connection code for embedded environments#9884
Light2Dark merged 1 commit into
mainfrom
sham/gdrive-local-webserver-flow

Conversation

@Light2Dark

@Light2Dark Light2Dark commented Jun 15, 2026

Copy link
Copy Markdown
Member

📝 Summary

Use out-of-band OAuth settings when marimo runs in an iframe (e.g. molab), and drop the explicit browser token for the default local flow. Browser token is unecessary because that's the default, it will default to "cache" if that's available too.

In iframe:

image

Note that this new argument auth_kwargs is only available in latest gdrive-fsspec (released a few days ago).

use_local_webserver: True doesn't work in molab due to molab not exposing a port 8000 to receive the access token. Making that work would require us to create our own oauth client, and to store the creds securely.

I've thought of a few ways we can clear the console but settled on this because it's the simplest.

  • mo.console.clear() like API? And call this in the code
  • Implement a custom UI/widget to display the URL, get the code etc.
  • OutputRenderer to detect text like "Enter the auth code", and to clear it

📋 Pre-Review Checklist

  • For large changes, or changes that affect the public API: this change was discussed or approved through an issue, on Discord, or the community discussions (Please provide a link if applicable).
  • Any AI generated code has been reviewed line-by-line by the human PR author, who stands by it.
  • Video or media evidence is provided for any visual changes (optional).

✅ Merge Checklist

  • I have read the contributor guidelines.
  • Documentation has been updated where applicable, including docstrings for API changes.
  • Tests have been added for the changes made.

Review in cubic

Use out-of-band OAuth settings when marimo runs in an iframe (e.g. molab),
and drop the explicit browser token for the default local flow.

Co-authored-by: Cursor <cursoragent@cursor.com>
Copilot AI review requested due to automatic review settings June 15, 2026 06:19
@vercel

vercel Bot commented Jun 15, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
marimo-docs Ready Ready Preview, Comment Jun 15, 2026 6:19am

Request Review

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@codecov

codecov Bot commented Jun 15, 2026

Copy link
Copy Markdown

Bundle Report

Changes will increase total bundle size by 10.38kB (0.04%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
marimo-esm 25.33MB 10.38kB (0.04%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: marimo-esm

Assets Changed:

Asset Name Size Change Total Size Change (%)
assets/JsonOutput-*.js 10.49kB 571.76kB 1.87%
assets/index-*.js 2.08kB 433.27kB 0.48%
assets/dist-*.js 131 bytes 387 bytes 51.17% ⚠️
assets/dist-*.js -107 bytes 169 bytes -38.77%
assets/dist-*.js 56 bytes 160 bytes 53.85% ⚠️
assets/dist-*.js 60 bytes 164 bytes 57.69% ⚠️
assets/dist-*.js -266 bytes 137 bytes -66.0%
assets/dist-*.js 9 bytes 169 bytes 5.62% ⚠️
assets/dist-*.js 17 bytes 276 bytes 6.56% ⚠️
assets/dist-*.js 231 bytes 335 bytes 222.12% ⚠️
assets/dist-*.js 6 bytes 183 bytes 3.39%
assets/dist-*.js -65 bytes 104 bytes -38.46%
assets/dist-*.js -79 bytes 104 bytes -43.17%
assets/dist-*.js -79 bytes 256 bytes -23.58%
assets/dist-*.js 81 bytes 183 bytes 79.41% ⚠️
assets/dist-*.js -46 bytes 137 bytes -25.14%
assets/dist-*.js -60 bytes 104 bytes -36.59%
assets/dist-*.js 8 bytes 177 bytes 4.73%
assets/dist-*.js -35 bytes 102 bytes -25.55%
assets/dist-*.js -211 bytes 176 bytes -54.52%
assets/dist-*.js 122 bytes 259 bytes 89.05% ⚠️
assets/dist-*.js 227 bytes 403 bytes 128.98% ⚠️
assets/layout-*.js 8 bytes 203.22kB 0.0%
assets/add-*.js 409 bytes 55.76kB 0.74%
assets/dependency-*.js -10 bytes 156.74kB -0.01%
assets/file-*.js 1 bytes 102.68kB 0.0%
assets/file-*.js -37 bytes 47.12kB -0.08%
assets/session-*.js -27 bytes 26.08kB -0.1%
assets/react-*.browser.esm-CV8-hvjx.js (New) 25.64kB 25.64kB 100.0% 🚀
assets/vega-*.browser-C8wT63Va.js (New) 24.8kB 24.8kB 100.0% 🚀
assets/home-*.js 8 bytes 24.18kB 0.03%
assets/command-*.js 8 bytes 18.34kB 0.04%
assets/react-*.esm-BNzu6e7h.js (New) 8.37kB 8.37kB 100.0% 🚀
assets/column-*.js -38 bytes 6.49kB -0.58%
assets/ttcn-*.js -7 bytes 57 bytes -10.94%
assets/ttcn-*.js 7 bytes 64 bytes 12.28% ⚠️
assets/emotion-*.esm-C59xfSYt.js (New) 4.37kB 4.37kB 100.0% 🚀
assets/tree-*.js 552 bytes 3.09kB 21.72% ⚠️
assets/components-*.js (Deleted) -2.58kB 0 bytes -100.0% 🗑️
assets/mermaid-*.core-B73Gp-Wo.js (New) 2.38kB 2.38kB 100.0% 🚀
assets/errors-*.js 171 bytes 1.1kB 18.43% ⚠️
assets/eye-*.js 182 bytes 612 bytes 42.33% ⚠️
assets/ellipsis-*.js (Deleted) -235 bytes 0 bytes -100.0% 🗑️
assets/react-*.browser.esm-BdtIs0E-.js (Deleted) -25.64kB 0 bytes -100.0% 🗑️
assets/vega-*.browser-xq8miGHn.js (Deleted) -24.8kB 0 bytes -100.0% 🗑️
assets/react-*.esm--O4lBTlZ.js (Deleted) -8.37kB 0 bytes -100.0% 🗑️
assets/emotion-*.esm-Dangy3Bv.js (Deleted) -4.37kB 0 bytes -100.0% 🗑️
assets/mermaid-*.core-Cw_lBEej.js (Deleted) -2.38kB 0 bytes -100.0% 🗑️
assets/maps-*.js (Deleted) -595 bytes 0 bytes -100.0% 🗑️

Files in assets/add-*.js:

  • ./src/components/editor/connections/storage/add-storage-form.tsx → Total Size: 3.79kB

  • ./src/components/editor/connections/storage/as-code.ts → Total Size: 5.29kB

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 4 files

Architecture diagram
sequenceDiagram
    participant UI as AddStorageForm
    participant Hook as useIframeCapabilities
    participant Gen as generateStorageCode
    participant GDrive as GoogleDriveFileSystem

    Note over UI,GDrive: Google Drive Connection Code Generation Flow

    UI->>Hook: Check iframe environment
    Hook-->>UI: isEmbedded boolean

    UI->>Gen: generateStorageCode(connection, { library, isEmbedded })

    alt Google Drive with service account credentials
        Gen->>Gen: generateGDriveCode() with credentials_json
        Gen-->>UI: fs = GoogleDriveFileSystem(token=..., use_listings_cache=False)
    else Google Drive default auth (not embedded)
        Gen->>Gen: generateGDriveCode(isEmbedded=false)
        Gen-->>UI: fs = GoogleDriveFileSystem(use_listings_cache=False)
    else Google Drive embedded auth (isEmbedded=true)
        Gen->>Gen: generateGDriveCode(isEmbedded=true)
        Gen-->>UI: fs = GoogleDriveFileSystem(use_listings_cache=False, auth_kwargs={"use_local_webserver": False})
        Note over UI: Also prints "Run this cell again to clear the console"
    end

    UI->>UI: Display generated code to user
Loading

Re-trigger cubic

@Light2Dark Light2Dark added the enhancement New feature or request label Jun 15, 2026
@Light2Dark Light2Dark requested review from akshayka and mscolnick June 15, 2026 16:39
@Light2Dark Light2Dark merged commit 3e52b5d into main Jun 15, 2026
43 of 51 checks passed
@Light2Dark Light2Dark deleted the sham/gdrive-local-webserver-flow branch June 15, 2026 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants