After some trial and error and more research I managed to come up with this solution which now allows me to authenticate a username and password against Magento.
It involves creating a PHP Script which I have uploaded to the Magento website currently its a proof of concept but I will add some more security such as a unique hash key which the mobile phone sends with the request over SSL of course and this along with the username and password will validate and get a Magento Session.
<?php
header('Content-Type: application/json');
// Get Post Vars
$username = addslashes($_REQUEST['username']);
$password = addslashes($_REQUEST['password']);
if ($username == "") {
echo json_encode(array('error','Access Denied'));
die();
}
if ($password == "") {
echo json_encode(array('error','Access Denied'));
die();
}
// Mage Path
require_once( dirname(__FILE__).'/app/Mage.php' );
// Initialize Magento ...
Mage::app("default");
$id = 1; // The Store ID.
$session = Mage::getSingleton('customer/session');
$status = true;
try {
$session->login($username, $password);
$session->setCustomerAsLoggedIn($session->getCustomer());
}catch ( Exception $e) {
$status = false;
}
if ($status == true) {
$userID = Mage::getSingleton('customer/session')->getId();
echo json_encode(array('status' => 1, 'userID' => $userID));
} else {
echo json_encode(array('status' => 0, 'message' => 'Access Denied'));
}
?>