close
Skip to content

Detect Jetpack JSON API module status before attempting wpcom-api auth#25

Open
jeherve wants to merge 1 commit intom:mainfrom
jeherve:fix/jetpack-json-api-detection
Open

Detect Jetpack JSON API module status before attempting wpcom-api auth#25
jeherve wants to merge 1 commit intom:mainfrom
jeherve:fix/jetpack-json-api-detection

Conversation

@jeherve
Copy link
Copy Markdown
Contributor

@jeherve jeherve commented Apr 10, 2026

Summary

The WordPress.com API returns the same error ("API calls to this blog have been disabled") for two different states: Jetpack connected but JSON API module off, and Jetpack installed but not connected at all. The connect agent had no way to distinguish these, so it would send users through the full OAuth flow only for API calls to fail afterward.

This adds a secondary check against the self-hosted /jetpack/v4/connection endpoint when we get that error. The hasConnectedOwner field tells us which state we're in, so we can give the user an accurate message and fall back to REST API + Application Password.

Test plan

Tested against a test site of mine in all three states:

  • Jetpack disconnected: WP.com API returns "disabled," hasConnectedOwner: false -> shows "Jetpack installed but not connected" message, falls back to REST API
  • Jetpack connected, JSON API module off: WP.com API returns "disabled," hasConnectedOwner: true -> shows "JSON API module not active" message, falls back to REST API
  • Jetpack connected, JSON API module on: WP.com API returns site info -> proceeds with wpcom-api OAuth (no change)

The WordPress.com API probe returns "API calls to this blog have been
disabled" for two different states: Jetpack connected but the JSON API
module is off, and Jetpack installed but not connected at all. Without
distinguishing these, the connect agent would send users through the
full OAuth flow only for API calls to fail afterward.

Check the self-hosted /jetpack/v4/connection endpoint when we get that
error; the hasConnectedOwner field tells us which state we're in. In
both cases, fall back to REST API + Application Password and let the
user know why.

Tested against test site in all three states: disconnected, connected
with module off, and connected with module active.
@jeherve jeherve force-pushed the fix/jetpack-json-api-detection branch from 22bfa72 to 600e1c6 Compare April 10, 2026 16:21
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.

1 participant