Skip to main content

Exchange OAuth authorization code for a WordPress JWT (GET)

GET 

/oauth/token

Browser-redirect flow: exchanges a provider authorization code for a WordPress session and redirects the browser to the WordPress admin (or login page on failure). The provider must be enabled in the plugin settings.

Supported providers: google, auth0, facebook, github.

Auth codes, IP allow-lists and the "Authentication enabled" setting do not apply to this endpoint; only the provider must be enabled.

Login start - provider only (no code, no error): the login buttons point here. The plugin stores a random state in a 10-minute HttpOnly cookie (sjl_oauth_state_<provider>) and answers 302 to the provider's consent screen with that state.

Callback - the provider redirects back with code and state. The callback is only accepted when state matches the cookie of the same browser (login CSRF protection); the cookie is single use. Otherwise the code is not exchanged and the browser is redirected to the login page with an error (error_code 129 in the audit log). Links that send visitors straight to the provider, without the login start, are rejected.

If the OAuth identity matches an existing WordPress user (by email), the user is logged in. If no match is found and "Register on OAuth login" is enabled, a new user is created automatically. On failure the browser is redirected to the WordPress login page.

Note: this endpoint is designed for browser redirect callbacks (OAuth consent screen redirect_uri). To obtain a JWT programmatically, use POST /oauth/token instead.

Request​

Responses​

The user has Two-Factor enabled: a small HTML page redirects the browser (meta refresh + JavaScript) to the wp-login.php?action=validate_2fa form of the Two Factor plugin. The session starts only after a valid code.