如何从Magento 1.7 REST API获取访问令牌和访问令牌密钥

16
我已在Magento管理后台注册了我的应用程序。
已经获得了Consumer Key和Consumer Secret。
但是我没有运气获得访问令牌和访问令牌密钥。
它说:
oauth_problem = parameter_absent&oauth_parameters_absent = oauth_consumer_key

Simple REST API

我正在基于这个链接进行测试。

http://www.magentocommerce.com/api/rest/testing_rest_resources.html

我需要知道答案的是:
  1. 我需要在标题和数据文本框中填写什么内容?
  2. 如何获取访问令牌和访问秘密令牌(在Mozilla上)?
  3. 是否有逐步测试任何REST API的教程?

4
你已经找到这个问题的解决方案了吗? - chanz
2
是的,我找到解决方法了。 - Josua Marcel C
@Josua Marcel Chrisano:你能否请发一下使用RESTClient的解决方案链接给我? - Remees M Syde
1个回答

6

0) 安装 https://chrome.google.com/webstore/detail/advanced-rest-client/hgmloofddffdnphfgcellkdfbfbjeloo 到你的 Chrome 浏览器中。

1) 使用以下命令获取 oAuth 客户端工具:

sudo gem install oauth

2) 配置Magento服务器

3) 获取oAuth令牌

oauth \
  --verbose \
   --query-string \
   --consumer-key v484mnii2jyswedm6uo2cfcjay7uy49snws \
   --consumer-secret koay6845che7giy5lr17gnrhckkbhf8h5 \
   --access-token-url http://www.yourstore.com/magento/oauth/token \
   --authorize-url http://www.yourstore.com/magento/oauth/authorize \
   --request-token-url http://www.yourstore.com/magento/oauth/initiate \
   authorize

回复:

Server appears to support OAuth 1.0a; enabling support.
Please visit this url to authorize:
http://www.yourstore.com/magento/oauth/authorize?oauth_token=ey6fokp0pbzwr1016eb528y5xw1ak5ji

Please enter the verification code provided by the SP (oauth_verifier):
YOUR_CODE_HERE

Response:
  oauth_token_secret: g9kyz8c7zv868d58eav1muih3gxvq763
  oauth_token: aqvlfv9tuexn0mqiydgkaff4ixxg8743c

4) 发送 API 请求

oauth \
    --consumer-key v484mnii2jyswedm6uo2cfcjay7uy49snws \
    --consumer-secret koay6845che7giy5lr17gnrhckkbhf8h5 \ 
    --token aqvlfv9tuexn0mqiydgkaff4ixxg8743c \
    --secret g9kyz8c7zv868d58eav1muih3gxvq763 \ 
    --uri http://www.yourstore.com/magento/api/rest/products \
    debug

尝试访问 http://www.yourstore.com/magento/api/rest/products


找到解决方案

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

php代码如下:

https://gist.github.com/2469319


你是如何使用oauth gem在命令行界面内逐行调用所有这些参数的API呢?还是只需要在命令行中输入一个长字符串即可? - Haris Ghauri

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接