Skip to content

docs: document per-viewer auth for Streamlit OAuth integrations#372

Draft
equiet wants to merge 2 commits into
mainfrom
docs/streamlit-federated-auth
Draft

docs: document per-viewer auth for Streamlit OAuth integrations#372
equiet wants to merge 2 commits into
mainfrom
docs/streamlit-federated-auth

Conversation

@equiet
Copy link
Copy Markdown
Contributor

@equiet equiet commented May 8, 2026

Summary

  • Add a new "Per-viewer authentication with OAuth integrations" section to docs/streamlit.md covering integrations that use federated auth (Snowflake OAuth/Okta/Azure AD, BigQuery Google OAuth, Trino OAuth), where the static env vars aren't populated.
  • Show how to use deepnote_toolkit.streamlit_data_apps helpers (get_snowflake_connection, get_bigquery_client) with worked examples, and explain the per-viewer authentication prompt flow.
  • Mention the lower-level get_federated_auth_token and prompt_federated_auth helpers for advanced use cases.

Test plan

  • Docs render correctly on the docs site
  • Code samples are accurate against the current deepnote_toolkit.streamlit_data_apps API

Made with Cursor

Summary by CodeRabbit

  • Documentation
    • Added a new section on per-viewer OAuth authentication explaining that integrations authenticate each viewer separately and do not rely on static environment variables.
    • Included setup guidance, end-user flow (first-open Authenticate button and reload), code examples for Snowflake/BigQuery, and documentation of helper utilities for creating viewer-scoped clients and prompting federated auth.

Add a Streamlit guide section explaining how to use
`deepnote_toolkit.streamlit_data_apps` helpers when an integration
relies on federated authentication (Snowflake OAuth/Okta/Azure AD,
BigQuery Google OAuth, Trino OAuth), since the static environment
variables aren't populated in that case.

Co-authored-by: Cursor <[email protected]>
@equiet equiet requested a review from a team as a code owner May 8, 2026 19:10
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 8, 2026

Review Change Stack

📝 Walkthrough

Hidden review stack artifact

Walkthrough

This PR adds a new documentation section to docs/streamlit.md covering per-viewer OAuth authentication for Streamlit data apps. The guide explains how to use deepnote_toolkit.streamlit_data_apps helpers to create viewer-scoped clients and connections for OAuth integrations (Snowflake, BigQuery, Trino). It includes working examples for Snowflake and BigQuery that use an INTEGRATION_ID, describes the automatic "Authenticate " button behavior on first app open, and documents lower-level helper functions for advanced use cases.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 5 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Updates Docs ⚠️ Warning Documentation added for features without corresponding implementation in the repository. Functions referenced don't exist in the codebase. Implement the documented helper functions or remove documentation to match actual API. Verify deepnote-internal repo has corresponding updates if helpers live elsewhere.
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change—documenting per-viewer authentication for Streamlit OAuth integrations in the docs.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 8, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.24%. Comparing base (b0afe05) to head (2a64f8c).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #372   +/-   ##
=======================================
  Coverage   82.24%   82.24%           
=======================================
  Files         144      144           
  Lines        5868     5868           
  Branches     1096     1142   +46     
=======================================
  Hits         4826     4826           
  Misses       1042     1042           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
docs/streamlit.md (1)

158-158: ⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Remove outdated limitation - contradicts the new OAuth section.

This line states OAuth integrations are "currently not supported", but lines 99-143 document exactly how to use them. Remove this limitation since OAuth support is now available.

🔧 Proposed fix
-- Snowflake and BigQuery integrations with federated authorization (OAuth) are currently not supported
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/streamlit.md` at line 158, Remove the outdated limitation sentence
"Snowflake and BigQuery integrations with federated authorization (OAuth) are
currently not supported" from the Streamlit docs so it no longer contradicts the
existing "OAuth" section; ensure the document references the OAuth setup
described in the OAuth section (the documented steps in lines ~99-143) and, if
needed, replace the removed sentence with a brief note pointing readers to the
OAuth section/header "OAuth" for integration instructions.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/streamlit.md`:
- Line 141: Remove the unnecessary backslashes before angle brackets in the
documentation text fragment "Authenticate \<integration name\>" so it reads
"Authenticate <integration name>" (i.e., edit the string in docs/streamlit.md
where the helper button description appears). Ensure you only remove the
backslashes and leave the rest of the sentence unchanged so Markdown renders the
angle-bracketed placeholder correctly.
- Around line 107-121: The docs include a non-existent function import
get_snowflake_connection in the Streamlit example which will raise ImportError;
either remove the example or mark it as a placeholder: update the snippet around
the Streamlit example (the block using get_snowflake_connection, INTEGRATION_ID,
pd.read_sql, and st.dataframe) to clearly state that get_snowflake_connection is
not yet implemented and provide a TODO or alternative guidance (e.g., instruct
users to supply their own DB connection or link to implementation plans) so the
documentation no longer references the missing function.

---

Outside diff comments:
In `@docs/streamlit.md`:
- Line 158: Remove the outdated limitation sentence "Snowflake and BigQuery
integrations with federated authorization (OAuth) are currently not supported"
from the Streamlit docs so it no longer contradicts the existing "OAuth"
section; ensure the document references the OAuth setup described in the OAuth
section (the documented steps in lines ~99-143) and, if needed, replace the
removed sentence with a brief note pointing readers to the OAuth section/header
"OAuth" for integration instructions.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 3bebdc52-f039-44a0-bf9b-41561e2a1b4d

📥 Commits

Reviewing files that changed from the base of the PR and between b0afe05 and 6330180.

📒 Files selected for processing (1)
  • docs/streamlit.md

Comment thread docs/streamlit.md
Comment on lines +107 to +121
```python
import streamlit as st
import pandas as pd
from deepnote_toolkit.streamlit_data_apps import get_snowflake_connection

INTEGRATION_ID = "<paste-integration-uuid-here>"

st.header('Snowflake table')

conn = get_snowflake_connection(INTEGRATION_ID)
df = pd.read_sql("SELECT * FROM DEEPNOTE.DEMO.COMPANIES", conn)
conn.close()

st.dataframe(df)
```
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.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify get_snowflake_connection exists and check its signature

# Find the deepnote_toolkit module
fd -t f -e py . | xargs rg -l "def get_snowflake_connection"

# Extract the function signature
rg -nP -A5 "def get_snowflake_connection" --type=py

Repository: deepnote/deepnote

Length of output: 43


🏁 Script executed:

# Search for streamlit_data_apps module
fd -t f -e py . | xargs rg -l "streamlit_data_apps"

Repository: deepnote/deepnote

Length of output: 45


🏁 Script executed:

# Search for any Snowflake connection functions
rg -n "snowflake.*connection\|get_snowflake" --type=py -i

Repository: deepnote/deepnote

Length of output: 43


🏁 Script executed:

# Check if deepnote_toolkit exists as a package/directory
fd -t d "deepnote_toolkit"

Repository: deepnote/deepnote

Length of output: 43


🏁 Script executed:

# Search for any references to the INTEGRATION_ID pattern or Snowflake examples
rg -n "INTEGRATION_ID\|Snowflake" docs/streamlit.md

Repository: deepnote/deepnote

Length of output: 43


🏁 Script executed:

# Read the actual content of docs/streamlit.md around lines 107-121
cat -n docs/streamlit.md | sed -n '100,130p'

Repository: deepnote/deepnote

Length of output: 1401


🏁 Script executed:

# Get total line count to verify file structure
wc -l docs/streamlit.md

Repository: deepnote/deepnote

Length of output: 83


🏁 Script executed:

# Find and list deepnote_toolkit directory structure
find deepnote_toolkit -type f -name "*.py" | head -20

Repository: deepnote/deepnote

Length of output: 113


🏁 Script executed:

# Search for any __init__.py files in deepnote_toolkit
find deepnote_toolkit -name "__init__.py" -exec cat {} +

Repository: deepnote/deepnote

Length of output: 113


🏁 Script executed:

# Search more broadly for streamlit in the codebase
rg "streamlit" --type=py -l

Repository: deepnote/deepnote

Length of output: 43


Remove or mark the Snowflake connection example as incomplete.

The code snippet at lines 107-121 imports deepnote_toolkit.streamlit_data_apps.get_snowflake_connection, but this function does not exist in the codebase and will fail with an ImportError. Either implement the API or indicate in the documentation that this is a placeholder example pending implementation.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/streamlit.md` around lines 107 - 121, The docs include a non-existent
function import get_snowflake_connection in the Streamlit example which will
raise ImportError; either remove the example or mark it as a placeholder: update
the snippet around the Streamlit example (the block using
get_snowflake_connection, INTEGRATION_ID, pd.read_sql, and st.dataframe) to
clearly state that get_snowflake_connection is not yet implemented and provide a
TODO or alternative guidance (e.g., instruct users to supply their own DB
connection or link to implementation plans) so the documentation no longer
references the missing function.

Comment thread docs/streamlit.md Outdated
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
docs/streamlit.md (1)

158-158: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Remove outdated limitation that contradicts new OAuth documentation.

This line claims OAuth integrations are not supported, but lines 99-144 document exactly that functionality. Remove this outdated limitation.

🗑️ Proposed fix
-- Snowflake and BigQuery integrations with federated authorization (OAuth) are currently not supported
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/streamlit.md` at line 158, Remove the outdated limitation sentence
"Snowflake and BigQuery integrations with federated authorization (OAuth) are
currently not supported" from the docs; it contradicts the OAuth integration
details already documented earlier (lines describing Snowflake/BigQuery OAuth
setup), so delete that single line to avoid confusion and ensure the Streamlit
doc is consistent.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/streamlit.md`:
- Around line 107-143: The doc examples reference non-existent helpers
get_snowflake_connection, get_bigquery_client, get_federated_auth_token, and
prompt_federated_auth which will cause import failures; either remove or rewrite
this section to match the actual public API (or implement those helpers). Fix by
deleting or replacing the example code blocks that import/use
get_snowflake_connection and get_bigquery_client and update the paragraph that
mentions get_federated_auth_token and prompt_federated_auth to reflect the real
functions/endpoints; if you choose to implement the helpers instead, add
functions with those exact names that wrap the existing auth/connection
primitives and export them from deepnote_toolkit.streamlit_data_apps so the
examples work as written.

---

Outside diff comments:
In `@docs/streamlit.md`:
- Line 158: Remove the outdated limitation sentence "Snowflake and BigQuery
integrations with federated authorization (OAuth) are currently not supported"
from the docs; it contradicts the OAuth integration details already documented
earlier (lines describing Snowflake/BigQuery OAuth setup), so delete that single
line to avoid confusion and ensure the Streamlit doc is consistent.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 0f3750e7-c47e-44d5-8b86-64632c3c5028

📥 Commits

Reviewing files that changed from the base of the PR and between 6330180 and 2a64f8c.

📒 Files selected for processing (1)
  • docs/streamlit.md

Comment thread docs/streamlit.md
Comment on lines +107 to +143
```python
import streamlit as st
import pandas as pd
from deepnote_toolkit.streamlit_data_apps import get_snowflake_connection

INTEGRATION_ID = "<paste-integration-uuid-here>"

st.header('Snowflake table')

conn = get_snowflake_connection(INTEGRATION_ID)
df = pd.read_sql("SELECT * FROM DEEPNOTE.DEMO.COMPANIES", conn)
conn.close()

st.dataframe(df)
```

A BigQuery app that connects via Google OAuth and renders a DataFrame:

```python
import streamlit as st
from deepnote_toolkit.streamlit_data_apps import get_bigquery_client

INTEGRATION_ID = "<paste-integration-uuid-here>"

st.header('BigQuery table')

client = get_bigquery_client(INTEGRATION_ID)
df = client.query("SELECT * FROM `bigquery-public-data.usa_names.usa_1910_current` LIMIT 100").to_dataframe()

st.dataframe(df)
```

You can find the integration UUID in the URL of the integration's settings page in your workspace.

The first time a viewer opens an app that uses an OAuth integration they have not authenticated yet, the helper renders an **Authenticate <integration name>** button that opens the same OAuth flow used by notebooks and published apps. After completing the sign-in, they reload the app and the query runs with their identity. Snowflake queries automatically use each viewer's username and (for Okta-mapped roles) their custom-attribute role.

If you need lower-level control, `get_federated_auth_token(integration_id)` returns the raw `{integrationType, accessToken, connectionParams}` payload, and `prompt_federated_auth(integration_id)` renders the authentication prompt without opening a connection.
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.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify all four helper functions exist in deepnote_toolkit

# Search for the streamlit_data_apps module
fd -t f -e py . | xargs rg -l "streamlit_data_apps"

# Search for each function definition
echo "=== Searching for get_snowflake_connection ==="
rg -nP "def get_snowflake_connection" --type=py -A3

echo "=== Searching for get_bigquery_client ==="
rg -nP "def get_bigquery_client" --type=py -A3

echo "=== Searching for get_federated_auth_token ==="
rg -nP "def get_federated_auth_token" --type=py -A3

echo "=== Searching for prompt_federated_auth ==="
rg -nP "def prompt_federated_auth" --type=py -A3

Repository: deepnote/deepnote

Length of output: 241


Remove or correct the documented helper functions—none currently exist in the codebase.

The documentation provides code examples (lines 107-137) that import and use get_snowflake_connection, get_bigquery_client, get_federated_auth_token, and prompt_federated_auth from deepnote_toolkit.streamlit_data_apps. These functions do not exist in the repository. Users following these examples will encounter immediate import failures. Either implement these helper functions or remove/rewrite this section to match the actual API.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/streamlit.md` around lines 107 - 143, The doc examples reference
non-existent helpers get_snowflake_connection, get_bigquery_client,
get_federated_auth_token, and prompt_federated_auth which will cause import
failures; either remove or rewrite this section to match the actual public API
(or implement those helpers). Fix by deleting or replacing the example code
blocks that import/use get_snowflake_connection and get_bigquery_client and
update the paragraph that mentions get_federated_auth_token and
prompt_federated_auth to reflect the real functions/endpoints; if you choose to
implement the helpers instead, add functions with those exact names that wrap
the existing auth/connection primitives and export them from
deepnote_toolkit.streamlit_data_apps so the examples work as written.

@jamesbhobbs jamesbhobbs marked this pull request as draft June 4, 2026 12:07
@jamesbhobbs
Copy link
Copy Markdown
Contributor

Converted to draft until Coderabbit feedback is addressed.

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.

2 participants