REST-API Endpoint /wp-json/jetpack/v4/connection/data fails with status code 401
-
Issue: Non-administrative shop manager user trigger multiple 40x HTTP status codes when accessing order overview in WordPress backend. This might trigger web application firewall to block remote IP.
Affected versions: WordPress 6.6.1, woocommerce 9.3.3, User Role Editor 4.64.2.
Solution: Add access right: “jetpack_connect_user” to your shop managers user group.
Explanation: Repeating call to REST-API
/wp-json/jetpack/v4/connection/data
fails (see HTTP server log) when backend user (shop manager, without full admin rights) is accessing the orders overview.[03/Nov/2024:13:22:10 +0100] "GET /wp-json/jetpack/v4/connection/data?_locale=user HTTP/2.0" 403 297 "https://<REDACTED>/wp-admin/admin.php?page=wc-orders"
Code block handling REST API endpoint calls:
woocommerce/vendor/automattic/jetpack-connection/src/class-rest-connector.php: 644
public static function user_connection_data_permission_check() { if ( current_user_can( 'jetpack_connect_user' ) ) { return true; } return new WP_Error( 'invalid_user_permission_user_connection_data', self::get_user_permissions_error_msg(), array( 'status' => rest_authorization_required_code() ) ); }
Apparently, any shop manager requires recently at least to have access right
jetpack_connect_user
, alternative woocommerce team might want to consider to switch to test foris_user_logged_in()
instead of this access right.Cheers,
Matthieu
- You must be logged in to reply to this topic.