Skip to content

Conversation

@bokelley
Copy link
Contributor

Summary

Fixes 500 error on tenant selection page after successful OAuth authentication.

Problem

The choose_tenant.html template was trying to unpack tuples:

{% for tenant_id, tenant_name in tenants %}

But the OAuth callback was passing a list of dictionary objects:

session["available_tenants"] = [
    {"tenant_id": "...", "name": "...", "subdomain": "..."}
]

This caused a 500 error when users successfully authenticated and reached the tenant selection page.

Solution

Updated the template to iterate over dictionaries directly:

{% for tenant in tenants %}
    <input type="radio" name="tenant_id" value="{{ tenant.tenant_id }}">
    <strong>{{ tenant.name }}</strong>

Testing

  • Template syntax is now compatible with the data structure passed from auth.py
  • This completes the unified OAuth flow where all users see the tenant selector with "Create New Account" option

Related

🤖 Generated with Claude Code

bokelley and others added 2 commits October 27, 2025 22:29
- Add logging for request context (URL, host, scheme)
- Log each step of redirect URI generation
- Add GOOGLE_OAUTH_REDIRECT_URI to .env.example with examples
- Will help diagnose redirect_uri_mismatch errors
The template was expecting tuples (tenant_id, tenant_name) but the OAuth
callback passes dictionary objects with keys: tenant_id, name, subdomain.

Changed the template iteration from:
  {% for tenant_id, tenant_name in tenants %}
To:
  {% for tenant in tenants %}

And updated field access to use dot notation (tenant.tenant_id, tenant.name).

This fixes the 500 error users encountered after successful OAuth authentication
when reaching the tenant selection page.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@bokelley bokelley merged commit aa612a3 into main Oct 28, 2025
9 checks passed
@bokelley bokelley deleted the fix-oauth-flow branch October 28, 2025 02:48
danf-newton pushed a commit to Newton-Research-Inc/salesagent that referenced this pull request Nov 24, 2025
…dcontextprotocol#652)

* debug: Add detailed OAuth redirect URI logging and env var documentation

- Add logging for request context (URL, host, scheme)
- Log each step of redirect URI generation
- Add GOOGLE_OAUTH_REDIRECT_URI to .env.example with examples
- Will help diagnose redirect_uri_mismatch errors

* fix: Update tenant selector template to work with dictionary objects

The template was expecting tuples (tenant_id, tenant_name) but the OAuth
callback passes dictionary objects with keys: tenant_id, name, subdomain.

Changed the template iteration from:
  {% for tenant_id, tenant_name in tenants %}
To:
  {% for tenant in tenants %}

And updated field access to use dot notation (tenant.tenant_id, tenant.name).

This fixes the 500 error users encountered after successful OAuth authentication
when reaching the tenant selection page.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
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