23.02.2015 Views

www.it-ebooks.info

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 6<br />

4. Next, we will be asked for the user <strong>info</strong>rmation as shown in the<br />

following screenshot:<br />

5. In the API Key and API Key Confirmation fields enter your desired password.<br />

6. Click on the User Role tab.<br />

7. Select the user role that we just created.<br />

8. Click on the Save User button.<br />

The reason that we need to create a username and role for accessing the API is that<br />

every single API function requires a session token to be passed as a parameter.<br />

For that reason, every time we need to use the API, the first call that we have to make<br />

is to the login function, which will return a valid session token ID.<br />

Setting up the REST API credentials<br />

The new RESTful API is slightly different in terms of authentication; instead of using<br />

the trad<strong>it</strong>ional Magento web service users, <strong>it</strong> uses a three-legged OAuth 1.0 protocol<br />

to provide authentication.<br />

OAuth works by asking the user to authorize <strong>it</strong>s application. When the user registers<br />

an application, he/she needs to fill in the following fields:<br />

• User: This is a customer, who has an account w<strong>it</strong>h Magento and can use the<br />

services w<strong>it</strong>h the API.<br />

• Consumer: This is a third-party application that uses OAuth to access the<br />

Magento API.<br />

[ 169 ]<br />

<strong>www</strong>.<strong>it</strong>-<strong>ebooks</strong>.<strong>info</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!