首页 文章

使用Magento REST API

提问于
浏览
1

我已经搜遍了(包括Stackoverflow),了解如何使用Magento REST API . 获取未经授权的请求令牌需要帮助(第一步)

在Magento设置上,我正在使用REST API为GET产品的客户工作,所以我知道这不是[问题] [1]

我已为上述URL设置了OAuth使用者,并同时具有使用者密钥和密钥 . 我无法弄清楚用于回调网址的URL .

首先,我在设置消费者时被卡住并且不知道我应该使用什么作为回调URL . 它是Magento中的可选字段

我按照http://www.magentocommerce.com/api/rest/testing_rest_resources.html测试Firefox REST客户端

接下来使用Firefox REST客户端,我无法通过获取未经授权的请求令牌开始 . 根据上面的URL我应该在 Headers 中有oauth_callback URI .

Authorization标头中应包含以下请求参数:oauth_callback - 服务提供商在授权完成后将资源所有者(用户)重定向到的URI . oauth_consumer_key - 在注册应用程序后检索的Consumer Key值 . oauth_nonce - 由应用程序唯一生成的随机值 . oauth_signature_method - 用于签署请求的签名方法的名称 . 可以具有以下值之一:HMAC-SHA1,RSA-SHA1和PLAINTEXT . oauth_signature - 生成的值(签名) . oauth_timestamp - 一个正整数,以1970年1月1日00:00:00 GMT之后的秒数表示 . oauth_version - OAuth版本 .

使用上述URL时oauth_callback URI是什么?

当我尝试POST到 Endpoint: /oauth/initiate

我明白了:

oauth_problem = parameter_absent&oauth_parameters_absent = oauth_callback

我知道还有什么可以尝试的 . 我'm a novice programmer and new to the Magento REST API...so keep that mind. It may be that I'我只是错过了明显的 .
任何有兴趣帮助我解决这个问题的人都是消费者密钥和秘密 .

key: d2f4a7cc63715f98d12db2c6db63cfba

secrect: 8347474102cbf2d40b06f9d76f281e73

网址为:http://temp.pramier.com

这是来自测试安装,所以我不担心发出密钥和秘密

3 回答

  • 1

    传递 oauth_callback ,如http://temp.pramier.com/admin . 你在这一步:

    获取未经授权的请求令牌


    验证用户的第一步是从Magento检索请求令牌 . 这是一个临时令牌,将被替换为访问令牌 .

    Endpoint: / oauth / initiate

    Description: 身份验证的第一步 . 允许您获取用于其余身份验证过程的请求令牌 .

    Method: POST

    Returns: 请求令牌

    Sample Response: oauth_token = 4cqw0r7vo0s5goyyqnjb72sqj3vxwr0h&oauth_token_secret = rig3x3j5a9z5j6d4ubjwyf9f1l21itrr&oauth_callback_confirmed = true


    你应该继续获得令牌 . 这是最好的(官方)教程:http://devdocs.magento.com/guides/m1x/api/rest/authentication/oauth_authentication.html#OAuthAuthentication-UsingOAuth

  • 0

    我不确定您使用的是哪种编程语言,但API列出了底部php中用于验证和检索产品的代码 .

    我刚刚开始使用代码here在ruby中处理这个问题 .

    @consumer=OAuth::Consumer.new auth["consumer_key"], 
                              auth["consumer_secret"], 
                              {:site=>"your-site-here"}
    
    @request_token = @consumer.get_request_token
    

    如果我误解了你的问题,或者在我的解释中不清楚,请告诉我 .

  • 0

    请按照这些说明操作:

    http://inchoo.net/magento/configure-magento-rest-and-oauth-settings/

    之后,请按照下列步骤操作:

    http://www.aschroder.com/2012/04/introduction-to-the-magento-rest-apis-with-oauth-in-version-1-7/

    在本文开头,作者要求使用名为oAuth的Ruby程序 . 如果您使用的是Linux,请将这些命令放入命令行以安装Ruby和oAuth:

    sudo apt-get install ruby

    sudo gem install oauth

    请注意,如果你准确地说:

    --authorize-url http://www.yourstore.com/magento/oauth/authorize \

    当您想要登录时,您将收到权限错误 . 您应该将其替换为:

    --authorize-url http://www.yourstore.com/magento/admin/oauth_authorize \
    

    一切都应该顺利进行 .

相关问题