如何在Ruby中验证oauth,Magento 2.0 SOAP



使用 oauth 凭据向 Magento 2 SOAP 进行身份验证时出现问题。

对于magento 1.9版本,这是非常简单的:

client = Savon.client(
wsdl: "https://example.com/api/soap/?wsdl=1",
log: true,
pretty_print_xml: true
)
session_id = client.call(:login, message: { username: "username", apiKey: "key" })body[:login_response][:login_return]
client.call(:call, message:{resource_path: 'catalog_product.list', session_id: session_id}).body

按预期工作。有了oauth,它变得更加复杂。 我尝试了各种不同的事情,比如:

client = Savon.client(
wsdl: "http://example.com/index.php/soap/default?wsdl_list=1",
soap_header: { 'Authorization:' => "Basic xxxx"},
pretty_print_xml: true
)
client.call(:call, message:{resource_path: 'catalogProductAttributeGroupRepositoryV1'}).body

希望有人已经做了一个oauth-magento 2肥皂集成,并给我一些指示。

您需要从管理员创建新的集成才能获取身份验证密钥。这些链接将是有用的资源:

https://devdocs.magento.com/guides/v2.0/get-started/authentication/gs-authentication-oauth.html https://gist.github.com/rafaelstz/ecab668b80fece4d9acdb9c5358b3173

最新更新