我试图使用V3访问WooCommerce REST的oAuth版本,以便在SSL上进行身份验证。
我所针对的运行WooCommerce的Wordpress实例使用AWSElasticBean秸秆托管。
当尝试使用oAuth时,我得到了401响应。请求所针对的URL是https://www.example.com/wc-api/v3/products?oauth_consumer_key=[my_key]&oauth_nonce=[nonce]&oauth_signature=[signature]%3D&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1453572852&oauth_token=&oauth_version=1.0&filter%5Blimit%5D=500
作为回应的一部分
[WWW-Authenticate] => Array
(
[0] => Basic realm="WooCommerce API. Use a consumer key in the username field and a consumer secret in the password field"
)我知道我使用的用户密钥和秘密都很好,因为我已经能够成功地在对同一站点的基本身份验证请求中使用它们。
我已经在我的开发环境(这不是在AWS上)中的一个非ssl地址上测试了相同的oAuth代码,它工作得很好。
我知道WooCommerce说您必须对http地址上的请求使用oAuth,但是对于https上的请求,您不能使用oAuth的情况正好相反吗?或者,我需要配置服务器端,这可能与AWS上的开发环境和生产环境不同吗?
发布于 2016-01-25 07:03:45
如果您查看woocommerce/includes/api/class-wc-api-authentication.php,authenticate函数会说:
if ( is_ssl() ) {
$keys = $this->perform_ssl_authentication();
} else {
$keys = $this->perform_oauth_authentication();
}这意味着您不能将oAuth用于https。(根据woocommerce的说法,你不需要。)
SSL加密请求不受嗅探或中间人攻击的影响,因此可以通过简单地查找与给定使用者密钥关联的用户并确认所提供的使用者机密是有效的来验证请求。
https://stackoverflow.com/questions/34967507
复制相似问题