WordPress OAuth 2.0 Server
For one reason or another WP OAuth Server and WooCommerce have a bit of a hard time understanding each other. This issue arises when you try to authenticate using OAuth 2.0 with the WooCommerce API. OAuth 2.0 specs require specific flows of request types but WooCommerce does not.
Note: If you are trying to view a protected endpoint (products, orders, users, etc), the access token MUST belong to a user that has “manager” capabilities. Currently, there is no workaround for this and is a limitation/restriction put in place by WooCommerce.
In someĀ scenarios, removing the PUT method from WP OAuth Server’s request controller will allow calls to be passed correctly through to WooCommerce. You can see some examples of filters below that will remove PUT if needed.
JSON API Solution
function wo_woo_api_fix( $methods ) { if ( ( $key = array_search( 'PUT', $methods ) ) !== false ) { unset( $methods[ $key ] ); } return $methods; } add_filter( 'wo_create_from_globals_json', 'wo_woo_api_fix' );
URLEncodeĀ POST Solution
function wo_woo_api_fix( $methods ) { if ( ( $key = array_search( 'PUT', $methods ) ) !== false ) { unset( $methods[ $key ] ); } return $methods; } add_filter( 'wo_create_from_globals_urlencoded', 'wo_woo_api_fix' );
Place this filter in the directory of the active theme or create a new plugin, add the function and activate the plugin.
By continuing to use the site, you agree to the use of cookies. more information
The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.