diff --git a/CLAUDE.md b/CLAUDE.md index 728be37d3..3d49d0b2b 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -135,3 +135,7 @@ A PR touching public API, config, or integration patterns is not complete until | `EXAMPLES.md` + `examples/` | `EXAMPLES.md` is an index; each feature has its own file under `examples/` with full Kotlin + Java usage | See [references/docs-update.md](references/docs-update.md) for the full code-to-docs mapping. Read before finalizing any public API PR. + +## Agent Skills + +For the integration gotchas (login, credentials, MFA, passkeys), read [`skills/SKILL.md`](skills/SKILL.md) and its sub-skills. They are not packaged in the AAR; consumers read them from the GitHub repo (`auth0/Auth0.Android`, `skills/`). Keep them in sync with `README.md` and `examples/` when public API changes. diff --git a/skills/SKILL.md b/skills/SKILL.md new file mode 100644 index 000000000..a3fccb289 --- /dev/null +++ b/skills/SKILL.md @@ -0,0 +1,58 @@ +--- +name: auth0-android +description: >- + Use when adding or changing Auth0 login in a native Android app with the + com.auth0.android:auth0 SDK, even if the user only says "add login to my + Android app". Lists where this SDK behaves differently from what you would + expect; the README and examples/ hold the how-to. +metadata: + library: Auth0.Android + library_version: 4.3.1 +--- + +# Auth0.Android + +Follow [README.md](../README.md) and [examples/](../examples/) for setup and +code. This file lists only where the SDK surprises agents. Each item has been +checked against the SDK source at the version above, so don't read the source +to confirm it. + +## Gotchas + +- **`withScope()` replaces the default scope.** The default is + `openid profile email`, with no `offline_access`, so no refresh token is + stored. Once the access token expires, `getCredentials` fails with + `CredentialsManagerException.NO_REFRESH_TOKEN`. Pass the full scope, including + `offline_access`, whenever the app keeps a session. +- **Only Web Auth validates the ID token.** `AuthenticationAPIClient` requests + skip validation unless you call `.validateClaims()`, and skipping it only logs + an error. Call it on every request that returns `Credentials`. +- **Login and logout each default to the `https` scheme.** If the app uses a + custom scheme, call `.withScheme()` on the logout builder too, not only on + login. With `https`, the callback only reaches the app once Android App Links + are verified for it. +- **`Credentials` has no claims map.** Read the user's claims from + `credentials.user`; custom claims are in `credentials.user.getExtraInfo()`. +- **README's first snippet hardcodes the client ID and domain.** Put them in + `strings.xml` and use `Auth0.getInstance(context)`, so they match the + `auth0Domain` manifest placeholder. +- **`customTokenExchange(subjectTokenType, subjectToken)` takes the type + first**, the reverse of `loginWithNativeSocialToken(token, tokenType)`. Both + are strings, so a swap compiles and fails at runtime. +- **Starting any Web Auth flow drops the one in progress.** A logout started + while a login is pending cancels that login without a callback. + +For MFA, read [mfa/SKILL.md](mfa/SKILL.md). For passkeys, read +[passkeys/SKILL.md](passkeys/SKILL.md). + +## Verify + +- `./gradlew assembleDebug` passes. +- Every `AuthenticationAPIClient` call that returns `Credentials` has + `.validateClaims()`. +- If the app stores credentials, the login scope includes `offline_access`. +- The callback and logout URLs in the Auth0 application are + `{scheme}://{domain}/android/{applicationId}/callback`. +- Waiting on the developer: sign in on a device, then call `getCredentials` + with a `minTtl` longer than the access token's lifetime and confirm it + returns renewed credentials. diff --git a/skills/mfa/SKILL.md b/skills/mfa/SKILL.md new file mode 100644 index 000000000..a0eb5f0af --- /dev/null +++ b/skills/mfa/SKILL.md @@ -0,0 +1,35 @@ +--- +name: auth0-android-mfa +description: >- + Use when adding multi-factor authentication to an Android app that uses + com.auth0.android:auth0, including handling mfa_required with the MFA API. +metadata: + library: Auth0.Android + library_version: 4.3.1 +--- + +# MFA with Auth0.Android + +Follow +[examples/authentication-api/mfa-flexible-factors.md](../../examples/authentication-api/mfa-flexible-factors.md) +for the code. These are the places agents go wrong. + +## Gotchas + +- **Use `authentication.mfaClient(mfaToken)`.** Version 4 removed + `loginWithOTP`, `loginWithOOB`, `loginWithRecoveryCode` and + `multifactorChallenge`; don't call them or hand-build `/oauth/token` MFA + requests. ([V4_MIGRATION_GUIDE.md](../../V4_MIGRATION_GUIDE.md)) +- **`mfaClient(...).verify()` doesn't validate the ID token**, and it has no + `validateClaims()`. Don't trust its ID token claims for access decisions. +- **The SDK doesn't wait for push approval.** It has no polling, so call + `verify` again on an interval while `error.getCode()` is + `authorization_pending`, and stop on success or any other error. + ([Auth0 docs](https://auth0.com/docs/secure/multi-factor-authentication/authenticate-using-ropg-flow-with-mfa/enroll-and-challenge-push-authenticators)) + +## Verify + +- `./gradlew assembleDebug` passes. +- No removed MFA method or hand-written `/oauth/token` request remains. +- Waiting on the developer: sign in with a user enrolled in the factor, complete + the challenge, and confirm the app receives credentials. diff --git a/skills/passkeys/SKILL.md b/skills/passkeys/SKILL.md new file mode 100644 index 000000000..83c4b7288 --- /dev/null +++ b/skills/passkeys/SKILL.md @@ -0,0 +1,39 @@ +--- +name: auth0-android-passkeys +description: >- + Use when adding passkey sign-up, sign-in or enrollment to an Android app that + uses com.auth0.android:auth0. +metadata: + library: Auth0.Android + library_version: 4.3.1 +--- + +# Passkeys with Auth0.Android + +Follow [examples/passkeys.md](../../examples/passkeys.md) and +[examples/my-account-api.md](../../examples/my-account-api.md) for the code. +These are the places agents go wrong. + +## Gotchas + +- **The app adds the passkey dependencies itself.** The SDK doesn't depend on + `androidx.credentials`, and its Gson isn't exposed, so add + `androidx.credentials:credentials`, `androidx.credentials:credentials-play-services-auth` + and `com.google.code.gson:gson` to the app module. +- **`signupWithPasskey` returns a challenge, not credentials.** The credentials + come from the later `signinWithPasskey` call, which needs `.validateClaims()`. +- **Enrolling a passkey for a signed-in user needs a My Account API token.** + `MyAccountAPIClient(auth0, accessToken)` accepts any token, but the API needs + one issued for `https://{domain}/me/`. Get it with + `credentialsManager.getApiCredentials("https://{domain}/me/", ...)`, which + needs a refresh token, so login must request `offline_access`. + ([My Account API](https://auth0.com/docs/manage-users/my-account-api)) + +## Verify + +- `./gradlew assembleDebug` passes with the three dependencies in the app module. +- `signinWithPasskey` calls have `.validateClaims()`. +- `MyAccountAPIClient` gets its token from `getApiCredentials` with the + `/me/` audience, not from the login credentials. +- Waiting on the developer: on a device with a screen lock, create a passkey, + sign out, and sign back in with it.