Skip to main content

Exchange OAuth token for a WordPress JWT (POST)

POST 

/oauth/token

API flow: exchanges a provider-issued token for a WordPress JWT and returns the WordPress user profile. Use this variant for programmatic API clients. The provider must be enabled in the plugin settings.

Supported providers: google, auth0, facebook, github.

Google - supply code (authorization code) or id_token (Google Sign-In ID token). The id_token path returns a WordPress JWT directly; the code path returns the raw Google token response for the client to handle. The id_token must be issued for the configured client ID (unless "Allow tokens issued for other Google clients" is enabled in the Google settings) and carry a verified email.

Auth0 - supply code (returns the raw Auth0 token response) or access_token (returns a WordPress JWT). The access_token must be a JWT issued for the configured Auth0 Client ID (azp or aud). Opaque access tokens are rejected (error code 79) unless "Allow opaque access tokens" is enabled in the Auth0 settings. The account email must be verified.

The code flow sends the provider the "exchange code" Redirect URI saved in the provider settings, so the code must have been issued for that URI.

Facebook - supply access_token (Facebook user access token). Returns a WordPress JWT. The token must have been issued for the configured Facebook app (checked with debug_token), and the App ID and App Secret must be set, unless "Allow tokens issued for other Facebook apps" is enabled in the Facebook settings.

GitHub - supply access_token (GitHub user access token). Returns a WordPress JWT. The token must have been issued for the configured GitHub OAuth app (personal access tokens are rejected), and the Client ID and Client Secret must be set, unless "Allow tokens issued for other GitHub apps" is enabled in the GitHub settings.

If the OAuth identity matches an existing WordPress user (by email), a WordPress JWT is returned. If no match is found and "Register on OAuth login" is enabled, a new user is created automatically.

Request​

Responses​

One of:

  • id_token / access_token flow: a WordPress JWT, or a 2FA challenge (two_factor_required: true, finish with POST /auth/2fa) when the user has Two-Factor enabled and the 2FA integration is on.
  • code flow: the raw token response of the provider, unchanged.