The crux of token-based authentication is as follows:
Client requests access with a username and password
Application validates credentials
Application provides a signed token to the client
The following code example demonstrates the console cURL REST-like request for the customer user:
curl -X POST "http://magento2.ce/rest/V1/integration/customer/token"\ -H "Content-Type:application/json"\ -d '{"username":"[email protected]", "password":"abc123"}'
The following code example demonstrates the PHP cURL REST-like request for the customer user:
$data = array('username' => '[email protected]', 'password' => 'abc123'); $data_string = json_encode($data); $ch = curl_init('http://magento2.ce/rest/V1/integration /customer/token'); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application...