Skip to content

Conversation

@pmalouin
Copy link
Contributor

@pmalouin pmalouin commented Nov 10, 2025

This PR introduces and showcases the connected accounts flow implementation by updating Auth0 SDK packages to their latest versions, fixing SPA example implementations, correcting documentation links throughout the codebase, and adding utility scripts for package management.

Note: This PR builds upon the connected accounts feature from the upstream PR

Key Changes

  • Updated Auth0 packages to support connected accounts:
    • @auth0/ai: ^5.0.1^5.1.1
    • @auth0/ai-langchain: ^4.0.0^4.1.0
    • @auth0/nextjs-auth0: 4.8.0^4.13.0
    • @langchain/langgraph-sdk: ^0.0.107^0.0.109
    • auth0: 4.33.04.35.0 (transient)
  • Token Vault Examples: Implemented the connected accounts flow in all examples
  • Component Refactoring: Reorganized Token Vault components for better maintainability:
  • Utility Scripts: Added scripts/update_packages.sh for automated package version management

🐛 Bug Fixes

  • Made SerpAPI truly optional:
    • ts-vercel-ai/src/lib/tools/serpapi.ts: Only include tool when API key is available
    • ts-llamaindex/src/lib/tools/serpapi.ts: Only include tool when API key is available
  • Fixed dependency issues:
    • Deduped @llamaindex/core by downgrading openai library version
    • Removed stray bun reference in ts-langchain/README.md
  • Updated tool scopes:
    • Gmail tool: Add the "openid" scope in ts-llamaindex/src/lib/tools/gmail.ts and ts-vercel-ai/src/lib/tools/gmail.ts
    • Google Calendar tool: Add the "openid" scope in ts-llamaindex/src/lib/tools/google-calender.ts and ts-vercel-ai/src/lib/tools/google-calender.ts

🛠️ Utility Scripts

  • Added scripts/update_packages.sh: Automated script for batch updating Auth0 packages across all examples
    • Supports npm package management
    • Updates package.json files and reinstalls dependencies
    • Handles all Auth0 packages: @auth0/ai, @auth0/ai-vercel, @auth0/ai-langchain, @auth0/ai-llamaindex, @auth0/auth0-spa-js, @auth0/nextjs-auth0

📁 Examples Updated

Python Examples

  • py-langchain (FastAPI + React/Vite frontend)
    • Backend auth configuration
    • Frontend TokenVault components
    • Package versions

TypeScript/Next.js Examples

  • ts-langchain (LangChain + Next.js)
  • ts-llamaindex (LlamaIndex + Next.js)
  • ts-vercel-ai (Vercel AI SDK + Next.js)

All examples updated with:

  • Connected accounts flow support
  • Updated Auth0 package versions
  • Fixed documentation links
  • Optional SerpAPI handling
  • Improved tool scopes

🧪 Testing

Manual Testing Required

  1. Connected Accounts Flow:
    - Test popup mode for account connection in all Next.js examples
    - Test redirect mode for account connection
    - Verify Token Vault token exchange works correctly
    - Confirm connected account tokens are properly managed
  2. Package Updates:
    - Verify all examples build successfully (npm run build)
    - Test that applications start without errors (npm run dev)
    - Confirm no dependency conflicts or warnings
  3. Optional Dependencies:
    - Test examples work without SerpAPI key (ts-vercel-ai, ts-llamaindex)
    - Verify tools are properly included/excluded based on API key availability
  4. Documentation Links:
    - Click through all README documentation URLs
    - Verify links resolve to correct documentation pages
  5. Functionality:
    - Test Gmail tool integration (if configured)
    - Test Google Calendar tool integration (if configured)


```bash
$ ANALYZE=true bun run build
$ ANALYZE=true npm run build

Choose a reason for hiding this comment

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


const tools = {
serpApiTool,
...(serpApiTool ? { serpApiTool } : {}),
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

- To start with the examples, you'll just need to add your OpenAI API key and Auth0 credentials for the Web app.
- You can setup a new Auth0 tenant with an Auth0 Web App and Token Vault following the Prerequisites instructions [here](https://auth0.com/ai/docs/call-others-apis-on-users-behalf).
- You can set up a new Auth0 tenant with an Auth0 Web App and Token Vault following the Prerequisites instructions [here](https://auth0.com/ai/docs/get-started/call-others-apis-on-users-behalf).
- An Auth0 FGA account, you can create one [here](https://dashboard.fga.dev). Add the FGA store ID, client ID, client secret, and API URL to the `.env` file.
Copy link
Contributor

@priley86 priley86 Nov 12, 2025

Choose a reason for hiding this comment

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

With this py-langchain example, on the backend it seems like we will need the equivalent of:

export const auth0 = new Auth0Client({
  enableConnectAccountEndpoint: true,
});

updated in the python sdk?

Also, seems we could likely also include the openid scope within:
https://github.com/auth0-samples/auth0-assistant0/blob/main/py-langchain/backend/app/core/auth0_ai.py#L17-L20

yes? (leaving as a reminder for later if this is the case)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, we'll need this change: auth0/auth0-fastapi#67
And this one: auth0/auth0-ai-python#55


- To start with the examples, you'll just need to add your OpenAI API key and Auth0 credentials for the Web app and Machine to Machine App.
- You can setup a new Auth0 tenant with an Auth0 Web App and Token Vault following the Prerequisites instructions [here](https://auth0.com/ai/docs/call-others-apis-on-users-behalf).
- You can set up a new Auth0 tenant with an Auth0 Web App and Token Vault following the Prerequisites instructions [here](https://auth0.com/ai/docs/get-started/call-others-apis-on-users-behalf).
Copy link
Contributor

Choose a reason for hiding this comment

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

(non-blocking): now wondering if we want to include all the Connected Account pre-req's in these READMEs, or just maintain in a singular place and link them in somehow?

Copy link
Contributor Author

@pmalouin pmalouin Nov 12, 2025

Choose a reason for hiding this comment

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

for now, kept the status-quo. But 💯 as discussed this morning, there might be an opportunity to revise layout of READMEs and whether some redundancy is warranted with the docs site (or not).

@priley86
Copy link
Contributor

tested ts-langchain, ts-llamaindex, and ts-vercel-ai examples to all work today, using step-up auth flow w/ My Accounts API changes introduced here, alongside the next.js auth0 sdk updates here (introduced locally w/ pnpm tgz packages). ✅

priley86
priley86 previously approved these changes Nov 17, 2025
@pmalouin pmalouin force-pushed the connected-accounts branch 2 times, most recently from 0cd554a to ef09c19 Compare November 19, 2025 13:32
@pmalouin pmalouin merged commit bf13d86 into main Nov 19, 2025
1 check passed
@pmalouin pmalouin deleted the connected-accounts branch November 19, 2025 13:38
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.

4 participants