oAuth访问令牌

时间:2016-09-14 14:15:24

标签: magento oauth oauth-2.0

你好我是oAuth的新手,我用这个例子创建了与Magento的休息连接

http://devdocs.magento.com/guides/m1x/api/rest/introduction.html

php脚本正常工作,我可以连接到magento。但我必须输入管理员凭据,之后我必须单击“授权”按钮。

现在我的“magento rest project”由数据库触发。所以我在最后几个小时搜索如何在没有真正点击按钮的情况下获得accessstoken? cli有什么类似的东西,甚至可能吗?

非常感谢你帮助我理解它。 欢呼拍拍

2 个答案:

答案 0 :(得分:0)

如果他们支持client credential grant,或者如果他们支持refresh tokens,则有可能支持authorization code grant。不幸的是,他们也不支持。

对于您正在实施的Magento docs,通过询问用户是否愿意允许您的客户访问其数据(以保护用户的隐私)来做出授权决定。这也在this is what the output currently looks like中提到。

答案 1 :(得分:0)

The built in Magento REST Api functionality doesn't support grant types other than authorization code grant.

I managed to use a customized oAuth2 library (https://bshaffer.github.io) (customizing the class so that it's compatible with the Zend Framework that magento is based on). It will let you choose your own grant type (in your case, Client Credential Grant).

The downside is that I had to re-create all the REST API endpoints. The upside is that it's not that hard, at least not harder than creating a custom endpoint using Magento's built in REST API functionality.