I need to develop an application driver that connect a CMS with Magento 2.0, using the SOAP API. My application is a Java J2SE and so I choose the axis2 project. I generate the code using the wsdl2Java tool and I'm able to create account using CustomerAccountManagementV1CreateAccountRequest command. Now I'm trying to get the customer repository using CustomerRepositoryV1GetListRequest, but I get the error message: "customer is not authorized to access %resources". I think I need to authenticate but I don't know how to do that. I hope someone could help, I do not have much time and I need a fast way to do that. Thanks
1 Answer
Yes, you are right, you need to send authentication header. How to authenticate for WebApi in Magento2 you can find here http://devdocs.magento.com/guides/v2.0/get-started/authentication/gs-authentication.html
-
thanks for your answer. I red the docs but I'm still confused: Mine is not a mobile apps and even a third party apps. In the first case auth token is used but they uses REST, I need SOAP! In the second OAuth but it looks like unnecessary and to complicated to me.– ssbandolCommented Dec 11, 2015 at 22:28
-
For development purposes you can create Bearer token using, for example, curl and REST
curl -X POST "http://magentohost/index.php/rest/V1/integration/admin/token" -H "Content-Type:application/json" -d '{"username":"admin", "password":"password"}'
As a result of this request you will get the Bearer token, e.g."tGzv3JOkF0XG5Qx2TlKWIA"
Then you should add this token to the authentication header in your SOAP request:"Authorization: Bearer tGzv3JOkF0XG5Qx2TlKWIA"
Commented Dec 12, 2015 at 18:25