How can I authenticate my users via our their Google Apps account. I also need access to their email.
I've read Oauth is needed but I have no idea if that is correct.
I'm using PHP.
How can I authenticate my users via our their Google Apps account. I also need access to their email.
I've read Oauth is needed but I have no idea if that is correct.
I'm using PHP.
I use this code in a library I wrote to pull contact information from gmail. http://www.oriontechnologysolutions.com/programming/libgoog_php. This particular function will validate an account and pass back an Auth Token used to access Google Services.
function login() {
$response = Array();
if(isset($this->domain))
$email = $this->username . '@' . $this->domain;
else
$email = $this->username;
$requestString = "service=".$this->service."&Email=".urlencode($email)."&Passwd=".urlencode($this->passwd)."&source=".self::source;
$c = curl_init();
curl_setopt($c, CURLOPT_URL, self::loginUrl);
curl_setopt($c, CURLOPT_POST, 1);
curl_setopt($c, CURLOPT_POSTFIELDS, $requestString);
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
$res = curl_exec($c);
$httpCode = curl_getinfo($c, CURLINFO_HTTP_CODE);
foreach(explode("\n", $res) as $line) {
if(strpos($line, "=") != false) {
gooDebug("Exploding $line\n", 4);
list($name, $value) = explode("=", $line);
$response[$name] = $value;
}
}
if($httpCode !=200)
return($response);
$this->authTok = $response['Auth'];
return($this->authTok);
}