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

Jos*_*ano 18 php api rest magento magento-1.7

我在我的magento admin上注册了我的应用程序.

已经获得消费者密钥和消费者秘密.

但我没有运气获得访问令牌和访问令牌秘密.

它说

oauth_problem = parameter_absent&oauth_parameters_absent = oauth_consumer_key

简单的REST API

我正在根据此链接进行测试

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

我需要知道答案是什么

  1. 我必须填写标题和数据文本字段?
  2. 如何获取访问令牌和访问机密令牌(在Mozilla上)?
  3. 是否有任何教程一步一步地测试任何REST API?

Jos*_*ano 8

0)将https://chrome.google.com/webstore/detail/advanced-rest-client/hgmloofddffdnphfgcellkdfbfbjeloo安装到您的Chrome

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

sudo gem install oauth
Run Code Online (Sandbox Code Playgroud)

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
Run Code Online (Sandbox Code Playgroud)

回复:

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
Run Code Online (Sandbox Code Playgroud)

4)进行API调用

oauth \
    --consumer-key v484mnii2jyswedm6uo2cfcjay7uy49snws \
    --consumer-secret koay6845che7giy5lr17gnrhckkbhf8h5 \ 
    --token aqvlfv9tuexn0mqiydgkaff4ixxg8743c \
    --secret g9kyz8c7zv868d58eav1muih3gxvq763 \ 
    --uri http://www.yourstore.com/magento/api/rest/products \
    debug
Run Code Online (Sandbox Code Playgroud)

尝试 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