首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >如何从Magento 1.7 REST API获取访问令牌和访问令牌密钥

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

Stack Overflow用户
提问于 2012-11-07 12:57:10
回答 1查看 24.8K关注 0票数 18

我已经在我的magento管理员上注册了我的应用程序。

已经得到了消费者密钥和消费者机密。

但是我没有机会得到访问令牌和访问令牌密钥。

上面写着

oauth_problem=parameter_absent&oauth_parameters_absent=oauth_consumer_key

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

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

我需要知道的答案是

  1. 我必须在报头和数据文本字段中填写什么?
  2. 如何获取访问令牌和访问密钥令牌(在Mozilla上)?
  3. 是否有分步测试REST API的教程?
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-12-20 12:03:44

0)将 安装到您的chrome

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

代码语言:javascript
复制
sudo gem install oauth

2)设置Magento服务器

3)获取oAuth令牌

代码语言:javascript
复制
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

回应:

代码语言:javascript
复制
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)调用接口

代码语言:javascript
复制
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

票数 8
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13263343

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档