【发布时间】:2017-08-11 19:41:46
【问题描述】:
我在 magento 中遇到了 oAuth 身份验证问题。
我使用以下指南创建连接: http://www.magentocommerce.com/api/rest/authentication/oauth_authentication.html
首先,我为 magento / System / WebServices / REST 中的所有帐户授予了所有权限......我还创建了 oAuth Consumer。我得到了两个变量(密钥和秘密)。
根据指南(获取未经授权的请求令牌),我为 Firefox 配置了 RESTClient。选择 oAuth 1.0 选项,从 magento 插入数据并将它们添加到标题中。
现在我有类似的东西:
http://www.mg19.local/oauth/initiate
OAuth oauth_version="1.0",
oauth_signature_method="PLAINTEXT",
oauth_nonce="pzmp8IZuroEP6gf",
oauth_timestamp="1410271763",
oauth_consumer_key="9ad2067e70a4c3b799ab2799203b3e3b",
oauth_signature="a37633084e79432568181ef00410140e%26"
如果我提交这个,我会得到以下错误:
状态码:400 错误请求
oauth_problem=parameter_absent&oauth_parameters_absent=oauth_callback
我不知道回调链接的主要用途,所以我使用了随机链接。例如:http://www.mg19.local
当我提交时
http://www.mg19.local/oauth/initiate/?oauth_callback=http://www.mg19.local
我得到以下结果:
oauth_token=e00fc8386ba523bdd1d79a2fe61d59cb&oauth_token_secret=ca0d999010b2b149e2d51feefc328722&oauth_callback_confirmed=true
根据指南,我移至第二步(用户授权):
我从对请求的响应中复制了数据。并转发链接:
http://www.mg19.local/oauth/authorize
我重定向到以下页面:
授权申请 邮递员请求访问您的帐户
授权后应用程序将可以访问您的帐户。
授权 |拒绝
当我选择授权时,我收到以下错误:
发生错误。您的授权请求无效。
使用xDebug我发现问题就在附近:
/**
* Load token object, validate it depending on request type, set access data and save
*
* @return Mage_Oauth_Model_Server
* @throws Mage_Oauth_Exception
*/
protected function _initToken()
{
....
} elseif (self::REQUEST_AUTHORIZE == $this->_requestType) {
if ($this->_token->getAuthorized()) {
$this->_throwException('', self::ERR_TOKEN_USED);
...
我不确定,但我认为,一旦成功完成自动化,我就会从索引转到帐户区域页面,当授权再次开始时 - 它失败了,我再次进入索引。
请给点建议。
【问题讨论】: