npx skills add ...
npx skills add auth0/agent-skills --skill auth0-java-mvc-common
npx skills add auth0/agent-skills --skill auth0-java-mvc-common
Use when adding Auth0 login, logout, or callback handling to a Java Servlet web application. Integrates com.auth0:mvc-auth-commons for server-side Java apps — use even if the user says "add login to my Java web app" without naming the library.
Add Auth0 authentication to Java Servlet web applications using com.auth0:mvc-auth-commons. Provides AuthenticationController for building authorize URLs and handling callbacks, with session-based authentication and support for Organizations and Multiple Custom Domains.
Agent instruction: Before providing SDK setup instructions, fetch the latest release version by running:
Use the returned version in all dependency lines instead of any hardcoded version below. If the API call fails, use
1.12.0.
auth0-quickstart skill first| Use Case | Recommended Skill |
|---|---|
| Spring Boot web applications with auto-configuration | Use Spring Boot + Okta starter for auto-configured Spring Boot login |
| Spring Boot REST APIs (stateless JWT) | Use auth0-springboot-api for JWT Bearer token validation |
| Single Page Applications | Use auth0-react, auth0-vue, or auth0-angular for client-side auth |
| Mobile applications | Use auth0-android or auth0-swift for native mobile |
| Machine-to-machine API calls | Use Auth0 Management API SDK for server-to-server |
Agent instruction: Do not write or echo credential values (domain, client ID, client secret) yourself. If the user's prompt already provides Auth0 credentials, skip the credential questions and instruct the user to populate their
.envfile — provide the variable names and file path but use placeholders (<YOUR_DOMAIN>,<YOUR_CLIENT_ID>,<YOUR_CLIENT_SECRET>), never actual values. Never repeat credentials back in responses.
Secret handling rules:
- Never retrieve or parse
client_secretfrom Auth0 CLI output.- Never write actual credential values into any file using the Write or Edit tool — always use placeholders and instruct the user to substitute their real values.
- Do NOT read
.envfiles (to avoid exposing existing secrets in context).- Always ensure
.envis in.gitignore— add the entry automatically if missing.
Gradle (build.gradle):
Maven (pom.xml):
You need a Regular Web Application (not SPA or Native) in Auth0.
STOP — ask the user before proceeding.
Ask exactly this question and wait for their answer before doing anything else:
"How would you like to create the Auth0 application?
- Automated — I'll run Auth0 CLI commands that create the application and write the values to your config automatically.
- Manual — You create the application yourself in the Auth0 Dashboard (or via
auth0 apps create) and provide me the Domain, Client ID, and Client Secret.Which do you prefer? (1 = Automated / 2 = Manual)"
Do NOT proceed to any setup steps until the user has answered. Do NOT default to manual.
If the user chose Automated, follow the Setup Guide [blocked] for the complete Auth0 CLI steps. The automated path writes configuration for you — skip Step 3 below and proceed directly to Step 4.
If the user chose Manual, follow the Setup Guide [blocked] (Manual Setup section). Then continue with Step 3.
Quick reference for manual application creation:
Or create manually in Auth0 Dashboard → Applications → Applications → Create Application → Regular Web Applications
Store credentials as environment variables (never hardcode in source):
Or use a .env file (add to .gitignore):
Agent instruction: Never write actual credential values to files. Instead, instruct the user to create or update
.envwith their credentials. Provide the template with placeholders only. Always add.envto.gitignoreif not already present. Warn the user: "Check your.envfor duplicate Auth0 entries if you've configured it previously."Java does not auto-load
.envfiles.System.getenv()only reads OS-level environment variables. If you generate a.envfile, you must also either: (1) add dotenv-java as a dependency and useDotenv.load().get("AUTH0_DOMAIN")instead ofSystem.getenv(), or (2) instruct the user to runsource .envbefore starting the server. Do not generate code that uses both a.envfile andSystem.getenv()without a loading mechanism — the values will benull.
Important: Domain must NOT include https://. The library constructs the issuer URL automatically.
Create a singleton AuthenticationController instance:
Agent instruction: After writing all code, verify the build succeeds:
or
mvn package. If build fails, diagnose and fix. After 5-6 failed attempts, useAskUserQuestionto get help.
http://localhost:3000/login/dashboard| Mistake | Fix |
|---|---|
Domain includes https:// | Use your-tenant.auth0.com format only — no scheme prefix |
| Client secret hardcoded in source | Use environment variables or .env file, add to .gitignore |
| Created SPA or Native app instead of Regular Web | Must create Regular Web Application in Auth0 Dashboard |
| Callback URL mismatch | Callback URL in code must exactly match what's registered in Auth0 Dashboard |
Missing openid scope | Always include openid in the scope — required for ID token |
Not handling IdentityVerificationException | Always catch this in the callback handler to show login errors |
Using response_type=token | Regular web apps must use code flow (the default) — never implicit |
| Session not invalidated on logout | Call request.getSession().invalidate() before redirecting to Auth0 logout |
See Integration Guide [blocked] for requesting custom scopes, audience for API access tokens, and Organizations support.
Built-in support for routing users to the correct Auth0 domain via DomainResolver. See Integration Guide [blocked] for configuration.
auth0-quickstart — Basic Auth0 setup and account creationauth0-springboot-api — Spring Boot REST APIs with JWT Bearer token validationCore Classes:
AuthenticationController — Main entry point, builds authorize URLs and handles callbacksAuthenticationController.Builder — Configures the controller via newBuilder(domain, clientId, clientSecret)AuthorizeUrl — Fluent builder for /authorize URL parametersTokens — Access token, ID token, refresh token from callbackIdentityVerificationException — Authentication error with error codeDomainResolver — Interface for Multiple Custom Domain supportBuilder Methods (AuthorizeUrl):
.withScope("openid profile email") — Set requested scopes.withAudience("https://my-api") — Request API access token.withOrganization("org_xxx") — Lock to specific Organization.withInvitation("invite_xxx") — Accept Organization invitation.withConnection("google-oauth2") — Skip to specific connection.withParameter("key", "value") — Add custom authorize parameterToken Access (Tokens):
tokens.getAccessToken() — Access token stringtokens.getIdToken() — ID token (JWT) stringtokens.getRefreshToken() — Refresh token (if offline_access scope requested)tokens.getExpiresIn() — Token expiration in secondstokens.getType() — Token type (usually "Bearer")tokens.getDomain() — Auth0 domain that issued the tokenstokens.getIssuer() — Token issuer URL