Magento Web Service – Web Service Connector Tool
TaskCentre can be used to automate calls to the Magento web service, REST or SOAP, using the Web Service Connector tool. Common interactions involve the download of sales orders and inventory, and the upload of order status updates etc.
For the tool to carry out requests on your behalf a set of Magento web access credentials must be supplied, i.e API keys. This article will show you how to obtain the keys from Magento and where they need to be placed within the Web Service Connector Tool.
The procedure is different for both REST and SOAP connections.
01 – Magento REST Connections
For a Magento REST connection you must supply the following:
- Consumer Key
- Secret Key
- API Key
Magento – Obtaining the Consumer and Secret Keys
Using the Magento admin panel the Consumer and Secret keys will be created.
- Login to the Magento admin panel.
- Navigate to System -> Web Services and select REST – OAUTH Consumers.
- Click Add New.
- Make a note of the Consumer and Secret keys.
- Supply a name then click Save to finish.
Web Service Connector Tool – Generating the API Key
The Consumer and Secret keys can now be passed to the Web Service Connector tool to generate the API key.
- Within TakCentre navigate to the Web Service Connector global configuration and open your Magento REST connection: Manage -> Tools -> Execute -> Web Service Connector
- Enter the Authentication tab and click the option Open authentication (OAUTH).
- Supply the Shared Secret and Consumer Key, obtained earlier.
- Select the Signature Method as HMAC-SHA1.
- Click Get Access Token and Secret.
- Enter the ‘GET Request Token URL root‘ followed by Next:
- Enter the ‘Login/Authorize Request Token service URL‘ followed by Next:
- Click the link Launch Web Browser to authorize token. This will open a browser window for you to obtain a ‘verifier code’. When prompted enter your Magento login credentials for the Admin Panel and click Authorize. Make a note of the Verifier code.
- Return to the Web Service Connector tool and enter the verifier code into the ‘Verification Code‘ field. Click Next to continue.
- Enter the ‘Get Access Token URL‘ followed by Finish:
All of the fields under ‘Open authentication (OAUTH)‘ should now be populated, the connection can now be closed.
This completes the procedure of enabling TaskCentre to authenticate with Magento each time a web call is made.
02 – SOAP Connections
For a Magento SOAP connection you must supply the following:
- User Name
- API Key
Magento API – Creating the User Name and API Key
Though the admin panel a new user will be created along with an API key.
- Login to the Magento admin panel.
- Navigate to System -> Web Services and select SOAP-XML-RPC-Users.
- Click Add New User.
- Complete all of the empty fields. The API key is user created and must be more than 6 characters long. The account by default is left as ‘Active‘. Make a note of the User Name and API Key that you just created.
- Click Save User to finish.
Web Service Connector Tool – Assigning the User Name and API Key to Constants
The User Name and API key will now be created as ‘Constants’ within the Magento SOAP connection at global level. This will enable them for mapping within the Web Service Connector tool and allow them to be mapped to parameters of the web service and passed with each web call.
- Within TaskCentre navigate to the Web Service Connector global configuration and open your Magento SOAP connection: Manage -> Tools -> Execute -> Web Service Connector
- Enter the Constants tab and create two constants called UserName and APIKey.
- Under the Name column, click in the blank row and enter ‘UserName‘. Click the next row down and enter ‘APIKey‘.
- Under the Value colunn, supply the name of the user and the API key you created in Magento.
- Click OK to save and finish.
Web Service Connector Tool – Mapping the Constants to Parameters in the Web Service
Within the tasks the Constants containing the username and API key must now be mapped to parameters of the Magento web service.
- Within the Mapping tab of the Web Service Connector tool, click Functions located on the right-hand side.
- Drag a Fixed/Dynamic function into the middle Transformation Mappings pane.
- Double-click the function to enter its properties then select the Value tab.
- From the task browser and under the Web Service Connector step, expand Constants and drag the UserName constant into the Output Text field.
- Click OK to finish.
- From the Tool Input pane on the right, expand Authentication and drag the Username parameter onto the username function to complete a mapping.
- Complete steps 1-6 to map the APIKey constant to the API key parameter.
This completes the procedure of allowing TaskCentre to authenticate with Magento each time a web call is made.
For further reading on Magento integration and our templated solution visit: Magento Connector Tool, or download the whitepaper below.