Skip to content

Allow headless application-password creation on Atomic sites #22884

@jkmassel

Description

@jkmassel

Summary

ApplicationPasswordsManager.getApplicationCredentials(site) returns NotSupported for any site.isWPCom site. The guard is correct for Simple sites but blocks Atomic sites, which are also isWPCom-flagged and do support REST app-password creation on their direct host.

Current state

libs/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpapi/applicationpasswords/ApplicationPasswordsManager.kt:45:

if (site.isWPCom) return ApplicationPasswordCreationResult.NotSupported(
    WPAPINetworkError(
        BaseNetworkError(
            GenericErrorType.UNKNOWN,
            "Simple WPCom sites don't support application passwords"
        )
    )
)

The error message says "Simple WPCom sites" but the predicate is isWPCom, which is true for Atomic too.

Why it matters

Atomic sites are full WordPress installs:

  • They accept WP.com bearer auth against the direct host (the same token we already send through the WP.com proxy).
  • They expose /wp/v2/users/me/application-passwords like any other WordPress install.

For Atomic sites without an application password we already have everything needed to mint one headlessly — same code path ORIGIN_WPCOM_REST (Jetpack) uses today — except this early return blocks it. Users have to go through the Chrome Custom Tab authorize-application.php flow even though the app could create the credential on their behalf.

What to do

Relax the guard to site.isWPComSimpleSite() (or site.isWPCom && !site.isWPComAtomic). For Atomic, route through the WP.com-bearer path (jetpackApplicationPasswordsRestClient.createApplicationPassword(site) or a sibling) so the call hits the direct host with bearer auth.

Things to verify:

  • The WP.com bearer is actually accepted by Atomic direct hosts on /wp/v2/users/me/application-passwords. The proxy already routes equivalent calls, so this should work, but worth confirming with a manual probe before wiring it in.
  • getOrFetchUsername works for Atomic. Today it branches on ORIGIN_WPCOM_REST only — Atomic falls into the else branch and would return site.username, which may or may not be set for Atomic sites added via the WP.com login flow.
  • Behaviour when the app password already exists on the server with the same name (409 / CONFLICT handling already exists in handleApplicationPasswordCreationResult).

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions