Skip to main content
Your web application doesn’t implement the browser join; Auth0 hosts it. Once completed, Auth0 redirects to your application’s Application Login URI, and your application starts its standard login flow. Your application needs to:
  1. Serve /.well-known/poppy.json and /.well-known/oauth-protected-resource.
  2. Accept the login that ends a join.
  3. Tell who is driving the browser, and never treat a guest as a user.
  4. Apply the agent’s scopes, and keep its session short.
The Auth0 Next.js and Express SDKs do the first three for you. On other Node.js frameworks, @auth0/auth0-server-js builds each piece, and your code mounts it.
To see it working first, follow the Quickstart: it adds Personal Agent Protocol to a sample store with a Next.js or an Express website.

Prerequisites

  • Your tenant set up for the Personal Agent Protocol, with the Auth0 CLI or manually, and the poppy.json it produced.
  • A Regular Web Application with the browser join turned on.
  • The beta release of your SDK: @auth0/nextjs-auth0@4.34.0-beta.0, @auth0/auth0-express@1.1.0-beta.0, or @auth0/auth0-server-js@1.18.0-beta.0.
  • Your website served over HTTPS at the root of your company domain. Agents look for the discovery files at the root, so the site can’t sit under a path.
  • Your web application logs in with the same API audience that agents get tokens for. Auth0 refuses a join login for another audience. The examples below set it from AUTH0_AUDIENCE.

Configure the application

In Dashboard > Applications > Applications, select your web application:
  1. Set Application Login URI to your SDK’s login route, such as https://shop.example/auth/login.
  2. Add your callback route, such as https://shop.example/auth/callback, to Allowed Callback URLs.
  3. (Recommended) Configure back-channel logout, so your application can end an agent’s session when Auth0 does.

Turn on Personal Agent Protocol in the SDK

Give the SDK your Poppy discovery document, the poppy.json file that auth0 poppy setup (or auth0 poppy config) writes. Every Auth0 web SDK takes it as it is. It serves the file unchanged at /.well-known/poppy.json, builds /.well-known/oauth-protected-resource from it, and checks only organization.domain and auth.issuer at startup. It serves the protocol version the file names and doesn’t check it. auth0 poppy doctor checks the rest of the file. The poppy.json file holds no secrets, so you can commit it. The sample app keeps it out of Git and writes one from its environment when a build has none.
poppy.json
lib/auth0.ts
The SDK serves the discovery files from your proxy, so its matcher must include /.well-known/*. This matcher does, because it excludes only static assets:
proxy.ts
On Next.js 15, name the file middleware.ts and the function middleware.
The Next.js and Express SDKs’ login routes now accept the redirect that ends a join. It checks the iss parameter against your issuer, and sends the browser to target_link_uri only when it’s on your own origin.

Tell who is driving the browser

After a join, the SDK classifies the login from the ID token:
  • Person: a normal login with no Poppy act claim.
  • Agent guest: an anonymous subject with a Poppy act claim. getSession() and getUser() return no user. Express and @auth0/auth0-server-js keep the guest in their own cookie. Next.js keeps it in the anonymous-session cookie, so getAnonymousSession() returns it.
  • Signed-in agent: the user’s session, with the agent kept in the session.
In client components, poppy.getContext() from @auth0/nextjs-auth0/client returns the same through the /auth/poppy-context route. It throws a PoppyError with poppy_not_enabled when the poppy option isn’t set.

Correlate activity with Sessions

Key Session state and events, such as a cart, by the Session ID and the User ID together, never by the Session ID alone. Agents choose their own Session IDs, so the Sessions of two users can have the same one. The key stays the same when a guest signs in, as long as the agent signs in within the same Poppy Session and with the same User ID. If either one differs, the key changes, so move the guest’s cart when the agent signs in if you need to keep it.
  • Express and other Node.js frameworks: use visitor.poppy.key, which the SDK builds from the Session ID and the User ID.
  • Next.js: combine poppy.act.poppy_sid and poppy.act.poppy_user_id. The guest cookie is deleted when the agent signs in, so save the guest’s key in your own storage first.
To learn more, read Correlate activity with Sessions.

Guard pages from guests

Scope what a guest can do as you would for any visitor who isn’t logged in. Route protection treats a guest as signed out. A guest can’t sign in from your login page: they sign in through the agent, which joins the browser again. As a result, don’t send a guest to your login page. In Express, requiresAuth() answers a guest with 403 instead of redirecting to login. To handle guests differently, use onGuest.

Apply the agent’s scopes

In scoped mode, the default, Auth0 limits your web application’s access token to the API and scopes the user approved for the agent. Ask for your API’s scopes at login (authorizationParameters.scope in Next.js, authorizationParams.scope with @auth0/auth0-server-js), so the joined token carries them and your API can check them. Your API calls from the web application are then limited for you. @auth0/auth0-express has no option for login scopes, so a joined token from an Express website carries none of your API’s scopes. Actions that your web application performs without calling that API aren’t limited by Auth0. Check the agent’s scopes before them, or set web.unscoped and describe poppy:browser-sign-in as full access. When you refuse an action for a missing scope, show an error that names the scope, so the agent can ask the user for it. Refuse agents on account changes that no scope covers, such as changing the email address or password. For sensitive operations, such as a payment, you can also require the user’s own confirmation when the tokens include an acting agent, for example with Client-Initiated Backchannel Authentication (CIBA).

Session lifetime and logout

  • Lifetime: the session a join creates lasts at most 2 hours, and Auth0 issues no refresh token for it. The SDKs cap the agent’s session at the ID token’s expiry. If your Sessions end sooner, end the website session too.
  • Sign-out at the agent: during the beta, revoking the agent’s refresh token doesn’t end the website’s signed-in session. It ends when it expires.
  • Logout: the SDK’s logout route ends the website session, including a guest’s, and the Auth0 session.

Check it works

Deploy your website, or open a tunnel to it, and fetch both discovery files. Each must name the other exactly, including the issuer’s trailing slash:
Then run the doctor, which compares them with your tenant:
For more troubleshooting steps, read Test Your Setup.

Next steps