Friday, July 18, 2008

Google Account Authentication - flex example

This example works for normal gmail accounts as well
as hosted accounts for e.g. kyz@some_domain_hosted_at_google.com.


<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="onAppInit()">

<mx:HTTPService id="requestClips"
url="https://www.google.com/accounts/ClientLogin"
result="handleHttpResponse(event)" method="POST" fault="handleFault()"/>

<mx:Script>
<![CDATA[
import mx.rpc.events.ResultEvent;
private function onAppInit()
{
// "accountType=&Email=".$uname."&Passwd=".$password."&
//source=Movico-MediaBaron-2.0";

var params:Object = {};
//requestClips.url = "http://localhost/MPC/check.php";
params["accountType"] = "HOSTED_OR_GOOGLE";
params["Email"] = "";//for e.g. abc@gmail.com
params["Passwd"] = "";//you know it.
params["source"] = "Company-App-version";
requestClips.send(params);
}
import mx.controls.Alert;
private function handleFault()
{
Alert.show("Either your username/password is incorrect or Google is down");
}
private function handleHttpResponse(event:ResultEvent)
{
var check:String = event.result.toString();
console.text = check;
Alert.show("Authentication Successful !");
}
]]>
</mx:Script>


<mx:TextArea id="console" width="100%" height="100%"/>

</mx:Application>


1 comment:

dms said...

Ok. But how can I get contacts from google contacts api ?

Thanks.

Blog Archive